无法传输工件org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from/to central(http://repo1.maven.org/maven2)

Saj*_*ith 60 java maven

我在SpringSource Tool Suite中创建了一个新的maven项目.我在新的maven项目中遇到此错误.

无法转移org.apache.maven.plugins:来自http://repo1.maven.org/maven2的 maven-surefire-plugin:pom:2.7.1 被缓存在本地存储库中,在更新间隔之前不会重新尝试解析中心已经过去或强制更新.原始错误:无法传输工件org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from/to central(http://repo1.maven.org/maven2):连接超时

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>com.test.app</groupId>
  <artifactId>TestApp</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>TestApp</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)

将Settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <pluginGroups>
  </pluginGroups>
 <proxies>
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>user</username>
      <password>pass</password>
      <host>ip</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>    
  </proxies> 
  <servers>  
  </servers>
    <mirrors>   
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://repo1.maven.org/maven2/</url>
    </mirror>    
  </mirrors>  
<profiles>
 </profiles>
</settings>
Run Code Online (Sandbox Code Playgroud)

请注意,我能够构建它.在IDE中的pom.xml中显示错误.任何解决方案?

car*_*ing 57

使用以下内容简化事物settings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              http://maven.apache.org/xsd/settings-1.0.0.xsd">

 <proxies>
    <proxy>
      <id>myproxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>user</username>  <!-- Put your username here -->
      <password>pass</password>  <!-- Put your password here -->
      <host>123.45.6.78</host>   <!-- Put the IP address of your proxy server here -->
      <port>80</port>            <!-- Put your proxy server's port number here -->
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts> <!-- Do not use this setting unless you know what you're doing. -->
    </proxy>    
  </proxies> 
</settings>
Run Code Online (Sandbox Code Playgroud)

在Linux/Unix下,将其放在下面~/.m2/settings.xml.在Windows下将其置于c:\documents and settings\youruser\.m2\settings.xmlc:\users\youruser\.m2\settings.xml.

你不需要的<mirrors/>,<profiles/>并且<settings/>部分,除非你真的知道自己在做什么的.

  • 好吧。在您的 IDE 中,确保它指向相同的“settings.xml”文件,因为您的代理设置显然没有被 IDE 获取。 (2认同)

Pet*_* T. 49

当我更新maven并在Eclipse中选中" 强制更新快照/版本 " 选项时,我就可以解决这个问题.这清除了所有错误.所以右键单击项目 - > Maven - > 更新项目,然后检查上面的选项 - > 确定.希望这对你有所帮助.

  • 在我的 elcipse (photon) versino 中看不到这个选项 (2认同)

Uda*_*kar 22

看来您的Maven无法连接到http://repo1.maven.org/maven2上的Maven存储库.

如果您使用代理并且可以使用浏览器访问该链接,则需要将相同的设置应用于Spring Source Tool Suite(如果您在套件中运行)或Maven.

对于Maven代理设置settings.xml,在.m2目录中创建一个包含以下详细信息

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <proxies>
    <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>PROXY</host>
      <port>3120</port>
      <nonProxyHosts>maven</nonProxyHosts>
    </proxy>
  </proxies>
</settings>
Run Code Online (Sandbox Code Playgroud)

如果您不使用代理并且可以使用浏览器访问该链接,请删除上述任何代理设置.


vsm*_*vsm 6

对我有帮助的是@carlspring的建议(创建一个settings.xml来配置你的http代理):

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              http://maven.apache.org/xsd/settings-1.0.0.xsd">

 <proxies>
    <proxy>
      <id>myproxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>user</username>  <!-- Put your username here -->
      <password>pass</password>  <!-- Put your password here -->
      <host>123.45.6.78</host>   <!-- Put the IP address of your proxy server here -->
      <port>80</port>            <!-- Put your proxy server's port number here -->
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts> <!-- Do not use this setting unless you know what you're doing. -->
    </proxy>    
  </proxies> 
</settings>
Run Code Online (Sandbox Code Playgroud)

然后按照@Peter T的建议刷新eclipse项目maven:

Eclipse 中的“强制更新快照/版本”。这会清除所有错误。因此右键单击项目 -> Maven -> 更新项目,然后选中上面的选项 -> 确定。希望这对您有帮助。


Eti*_*ret 5

看来我是网络问题。在你这边,或者在 Maven 这边,或者中间的任何地方。请稍后再试。

如果错误是永久性的,请检查您的网络设置。如果您使用代理,则需要在 ~/.m2/settings.xml 中包含以下内容:

<proxies>
    <proxy>
        <id>optional</id>
        <active>true</active>
        <protocol>http</protocol>
        <username>proxyuser</username>
        <password>proxypass</password>
        <host>proxy.host.net</host>
        <port>80</port>
        <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
</proxies>
Run Code Online (Sandbox Code Playgroud)


Sam*_*Rad 5

对于第一个错误,您可以简单地清除本地存储库缓存以强制从主存储库下载而不是检查本地存储库缓存.

对于第二个错误,如果您在代理后面,则应该以这种方式配置配置代理,否则您现在遇到网络问题.


Ali*_*786 5

对我来说,解决方案只是删除了给出错误的特定文件夹 ~/.m2/repository/org/hsqldb/

删除hsqldb文件夹后,我已经构建了项目,一切都很好.