无法在maven项目中添加springframe工作
我试图在maven项目中添加spring核心和spring上下文,但在构建时,我遇到了以下错误,我试图访问以下编译错误的前3行中给出的三个存储库:无法在maven项目中添加springframe工作,spring,eclipse,maven,Spring,Eclipse,Maven,我试图在maven项目中添加spring核心和spring上下文,但在构建时,我遇到了以下错误,我试图访问以下编译错误的前3行中给出的三个存储库: [INFO] Downloading from : http://repo1.maven.org/maven2/org/springframework/spring-context/4.0.0.RELEASE/spring-context-4.0.0.RELEASE.pom [INFO] Downloading from : https://repo
[INFO] Downloading from : http://repo1.maven.org/maven2/org/springframework/spring-context/4.0.0.RELEASE/spring-context-4.0.0.RELEASE.pom
[INFO] Downloading from : https://repo.spring.io/milestone/org/springframework/spring-context/4.0.0.RELEASE/spring-context-4.0.0.RELEASE.pom
[INFO] Downloading from : https://repo.maven.apache.org/maven2/org/springframework/spring-context/4.0.0.RELEASE/spring-context-4.0.0.RELEASE.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.622 s
[INFO] Finished at: 2018-10-05T18:18:19+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project HelloWorldMaven: Could not resolve dependencies for project Demo:HelloWorldMaven:jar:0.1: Failed to collect dependencies at org.springframework:spring-context:jar:4.0.0.RELEASE: Failed to read artifact descriptor for org.springframework:spring-context:jar:4.0.0.RELEASE: Could not transfer artifact org.springframework:spring-context:pom:4.0.0.RELEASE from/to central (http://repo1.maven.org/maven2): connect timed out -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
以下是我的POM.xml,我在其中添加了依赖项:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Demo</groupId>
<artifactId>HelloWorldMaven</artifactId>
<version>0.1</version>
<name>Hello world demo</name>
<description>Hello world demo</description>
<properties>
<org.springframework-core-version>4.0.0.RELEASE</org.springframework-core-version>
<org.springframework-context-version>4.0.0.RELEASE</org.springframework-context-version>
<log4j-version>1.2.17</log4j-version>
<junit-version>4.12</junit-version>
</properties>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j-version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework-core-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-context-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
4.0.0
演示
HelloWorldMaven
0.1
你好世界演示
你好世界演示
4.0.0.0发布
4.0.0.0发布
1.2.17
4.12
log4j
log4j
${log4j版本}
org.springframework
弹簧芯
${org.springframework核心版本}
org.springframework
spring上下文
${org.springframework上下文版本}
朱尼特
朱尼特
${junit版本}
maven汇编插件
完全合格
带有依赖项的jar
请帮助,我无法找出我缺少的内容,我想我无法访问远程存储库。
请帮忙。提前感谢。您可能有代理,或者您当前的网络需要代理,或者您的连接不稳定
到中央(http://repo1.maven.org/maven2):连接超时->
我在我的setting.xml中添加了以下内容
真的
http
我的主人地址
我的港口
并与
干净安装-DproxySet=true-DproxyHost=my.host.address-DproxyPort=myPort
成功了 网络问题:
从/到中心(http://repo1.maven.org/maven2):连接超时…
可能是什么问题?因为我能够到达页面http://repo1.maven.org/maven2/org/springframework/spring-context/4.0.0.RELEASE/spring-context-4.0.0.RELEASE.pom
在我的浏览器中。我想再问一个问题,我的.m2存储库中有springframework,那么为什么在编译期间,它正在通过中央存储库获取它?我的存储库中有这些文件@${my_home}\.m2\repository\springframework\spring context\4.0.0.RELEASE==>\u remote.repositories,m2e-lastUpdated.properties,spring-context-4.0.0.RELEASE.jar,spring-context-4.0.0.RELEASE.jar.sha1,spring-context-4.0.0.RELEASE.pom,spring-context-4.0.0.RELEASE.pom.lastUpdated,spring-context-4.0.0.RELEASE.pom.sha1,spring-context-4.0.0.RELEASE-javadoc.jar.lastUpdated,spring-context-4.0.0.RELEASE-sources.jar.lastUpdated但如果使用此URL->http://repo1.maven.org/maven2/org/springframework/spring-context/4.0.0.RELEASE/spring-context-4.0.0.RELEASE.pom
在我的浏览器中,我可以访问该页面,这意味着我的网络允许我访问该页面,不是吗?我的.m2存储库中有springframework,那么为什么它要去中央存储库获取springframework呢?我已经尝试了mvn clean install-o
并添加了
标签,但它仍然会被放到中央存储库中,我不知道为什么!!浏览器可以有自己的代理,命令行/maven可以有自己的代理。您必须设置浏览器正在使用的代理/证书,或者禁用maven Entrelyi添加的代理设置中的代理/证书,并使用clean install-dproxy set=true-dproxy host=my.host.add-dproxy port=myport运行该项目现在运行正常。谢谢这是正确的做法吗@陈金龙
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>my.host.address</host>
<port>myPort</port>
</proxy>
</proxies>