首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在maven项目中添加springframe工作

无法在maven项目中添加springframe工作
EN

Stack Overflow用户
提问于 2018-10-05 21:01:13
回答 2查看 47关注 0票数 0

我试图在一个maven项目中添加spring-core & spring-context,但在构建时,我得到了以下错误,我试图访问以下编译错误的前3行中给出的三个存储库:

代码语言:javascript
复制
[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:

代码语言:javascript
复制
    <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>

请帮帮我,我不能弄清楚我错过了什么,我想我无法访问远程存储库。请帮帮忙。提前谢谢。

EN

回答 2

Stack Overflow用户

发布于 2018-10-06 01:02:59

您可能在代理服务器之后,或者您当前的网络需要代理服务器,或者您的连接不稳定

to central (http://repo1.maven.org/maven2): connect timed out ->

票数 1
EN

Stack Overflow用户

发布于 2018-10-08 16:46:11

我在我的setting.xml中添加了以下内容

代码语言:javascript
复制
    <proxies>
   <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>my.host.address</host>
      <port>myPort</port>
    </proxy>
  </proxies>

并运行了这个项目

全新安装-DproxySet=true -DproxyHost=my.host.address -DproxyPort=myPort

它成功了!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52666230

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档