无法在Maven项目中添加springframe工作

时间:2018-10-05 13:01:13

标签: spring eclipse maven

我正在尝试在Maven项目中添加spring-core和spring-context,但是在构建时,我遇到以下错误,我正在尝试访问下面的编译错误的前三行中给出的三个存储库: / p>

[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>

请帮助,我无法弄清丢失的内容,我想我无法访问远程存储库。 请帮忙。提前谢谢。

2 个答案:

答案 0 :(得分:1)

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

out = np.broadcast_to(arr, (120, 100, 3)).copy()

答案 1 :(得分:0)

我在 setting.xml

中添加了以下内容
    <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

成功了!