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

时间:2022-02-02 17:14:25

I have created a new maven project in SpringSource Tool Suite. I am getting this error in a new maven project.

我在SpringSource工具套件中创建了一个新的maven项目。我在一个新的maven项目中得到这个错误。

Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from/to central (http://repo1.maven.org/maven2): Connect times out

从http://repo1.maven.org/maven2缓存到本地存储库中,直到中心的更新间隔或更新被强制执行时,才会重新尝试解析。原始错误:无法传输工件org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from/to central (http://repo1.maven.org/maven2):连接超时。

pom.xml:

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>

Settings.xml

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>

Please not that I am able to biuld it.Error is showing in pom.xml inside IDE .Any solutions?

请不要说我能把它画好。错误显示在pom中。xml内部的xml,有什么解决方案吗?

15 个解决方案

#1


39  

Simplify things by using the following 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>

Under Linux/Unix, place it under ~/.m2/settings.xml. Under Windows place it under c:\documents and settings\youruser\.m2\settings.xml or c:\users\youruser\.m2\settings.xml.

在Linux/Unix下,将其置于~/.m2/settings.xml中。在Windows下将其置于c:\文件和设置\youruser\.m2\设置。xml或c:\ \用户对于\ .m2 \ settings.xml。

You don't need the <mirrors/>, <profiles/> and <settings/> sections, unless you really know what they're for.

您不需要 <镜像 />, 和 <设置 />部分,除非您真的知道它们是什么。

#2


27  

This is solved for me when I update maven and check the option "Force update of Snapshots/Releases" in Eclipse. this clears all errors. So right click on project -> Maven -> update project, then check the above option -> Ok. Hope this helps you.

当我更新maven并检查Eclipse中的“快照/发布的强制更新”选项时,这个问题就解决了。清除所有错误。所以右键单击project -> Maven ->更新项目,然后检查上面的选项-> Ok。希望这能帮助你。

#3


19  

It seems like your Maven is unable to connect to Maven repository at http://repo1.maven.org/maven2.

似乎您的Maven无法连接到Maven存储库http://repo1.maven.org/maven2。

If you are using proxy and can access the link with browser the same settings need to be applied to Spring Source Tool Suite (if you are running within suite) or Maven.

如果您正在使用代理,并且可以使用浏览器访问链接,那么需要将相同的设置应用到Spring源工具套件(如果您在套件中运行)或Maven。

For Maven proxy setting create a settings.xml in the .m2 directory with following details

对于Maven代理设置创建一个设置。在.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>

If you are not using proxy and can access the link with browser, remove any proxy settings described above.

如果您没有使用代理,并且可以使用浏览器访问该链接,请删除上面描述的任何代理设置。

#4


5  

For the first error you can simply clear your local repository cache to force it download from main repository rather than checking the local one.

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

For second error, if you are behind proxy you should configure it this way Configuring a proxy otherwise you have a network problem now.

对于第二个错误,如果你是在代理后面,你应该配置它来配置一个代理,否则你现在有一个网络问题。

#5


3  

To me the solution was just deleted the specific folder which is giving the error from ~/.m2/repository/org/hsqldb/

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

After deleting the hsqldb folder I have build the project and everything is fine.

在删除hsqldb文件夹之后,我构建了这个项目,一切都很好。

#6


3  

What helped me were the suggestions by @carlspring (create a settings.xml to configure your http proxy):

@carlspring的建议(创建一个设置)帮助了我。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>

AND then refreshing eclipse project maven as suggested by @Peter T :

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

"Force update of Snapshots/Releases" in Eclipse. this clears all errors. So right click on project -> Maven -> update project, then check the above option -> Ok. Hope this helps you.

“在Eclipse中强制更新快照/发布”。清除所有错误。所以右键单击project -> Maven ->更新项目,然后检查上面的选项-> Ok。希望这能帮助你。

#7


2  

It seems me there was a network issue. On your side, or on Maven side, or anywhere in the middle. Just try again later.

我好像有网络问题。在你这边,或者在Maven边上,或者在中间的任何地方。稍后再试。

If the error is permanent, check your network settings. If you are behind a proxy, you need the following in you ~/.m2/settings.xml:

如果错误是永久性的,请检查您的网络设置。如果你在一个代理后面,你需要在你的~/.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>

#8


2  

I strongly recommend to use a Maven Repository Manager such as Nexus. It will help you to get stable and reproducible builds with Maven. As the Repository Manager is usually in your LAN, you don't have to configure the proxy settings, but you need to define some other configurations:

我强烈建议使用Maven存储库管理器,比如Nexus。它将帮助您获得稳定和可复制的构建与Maven。由于存储库管理器通常在您的LAN中,所以您不必配置代理设置,但是您需要定义一些其他配置:

http://www.sonatype.com/books/nexus-book/reference/maven-sect-single-group.html

http://www.sonatype.com/books/nexus-book/reference/maven-sect-single-group.html

http://maven.apache.org/repository-management.html

http://maven.apache.org/repository-management.html

#9


1  

If none of the above works then try and go this question and answer: Maven error "Failure to transfer..."

如果以上这些都不可行,那么请尝试回答以下问题:Maven错误“传输失败……”

and delete your .lastUpdated files.

并删除您的. lastupdated文件。

#10


1  

I started using maven on my machine first time in while. Got this error: Could not transfer artifact from/to central (https://repo.maven.apache.org/maven2) No such file or directory Cleaned up ~/.m2/repository directory. Don't experience this problem again

我开始在我的机器上第一次使用maven。得到这个错误:不能将工件从/中转移到中心(https://repo.maven.apache.org/maven2),没有这样的文件或目录清理~/。m2 /存储库目录中。不要再体验这个问题了。

#11


1  

  1. Update Maven Project and check the option "Force update of Snapshots/Releases", it will remove errors.
  2. 更新Maven项目并检查“快照/发布的强制更新”选项,它将清除错误。
  3. If not, Maven clean and install the Project.
  4. 如果没有,Maven将清理并安装该项目。
  5. Still the error isn't removed, repeat step 1.
  6. 仍然没有删除错误,重复步骤1。

It worked for me :)

它为我工作:

#12


0  

If you are in windows os and dont need any proxy then delete the whole proxy setting

如果您在windows操作系统中,不需要任何代理,那么就删除整个代理设置。

<proxies>
    <proxy>
   ..................
    </proxy>    
  </proxies> 

and replace with

和替换

<proxies/> 

and then do a maven clean build

然后做一个maven的清洁构建。

#13


0  

This problems was a network issue.

这是一个网络问题。

  1. Go to the local repository and find the directory org/apache/maven/plugins/maven-surefire-plugin.

    转到本地存储库,找到目录org/apache/maven/plugins/maven-surefire-plugin。

  2. Delete the correspond version of it.

    删除相应的版本。

  3. maven update the project, then download it again.

    maven更新项目,然后再次下载。

#14


0  

If you are not behind any proxy and still getting connection timeout error, please check firewall settings/ antivirus. Sometimes firewall may block the connectivity from any tool (like Eclipse/STS etc..)

如果您不支持任何代理,并且仍然有连接超时错误,请检查防火墙设置/反病毒。有时,防火墙可能会阻止任何工具(如Eclipse/STS等)的连接。

#15


0  

We have the Proxy set on company level.

我们有公司级别的代理。

After disabling proxy in Internet Explorer this issue was solved (looks like it is then disabled on 'system' level), so all other browsers will pick this change too.

在Internet Explorer中禁用代理之后,这个问题得到了解决(看起来在系统级别上是禁用的),所以所有其他浏览器也会选择这个更改。

Now I can issue MVN commands from CMD prompt and I have no problem while e.g.

现在我可以在CMD提示符下发出MVN命令,而我没有问题。

"Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-webapp/1.0/maven-archetype-webapp-1.0.pom"

“下载:https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-webapp/1.0/maven-archetype-webapp-1.0.pom”

...that was causing 'Build failure'

…这导致了“构建失败”

Disabling proxy in IE needs to be done on daily basis in our case, because on each system start it gets set

在我们的情况下,在IE中禁用代理需要在日常的基础上完成,因为在每个系统启动时它都会被设置。

#1


39  

Simplify things by using the following 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>

Under Linux/Unix, place it under ~/.m2/settings.xml. Under Windows place it under c:\documents and settings\youruser\.m2\settings.xml or c:\users\youruser\.m2\settings.xml.

在Linux/Unix下,将其置于~/.m2/settings.xml中。在Windows下将其置于c:\文件和设置\youruser\.m2\设置。xml或c:\ \用户对于\ .m2 \ settings.xml。

You don't need the <mirrors/>, <profiles/> and <settings/> sections, unless you really know what they're for.

您不需要 <镜像 />, 和 <设置 />部分,除非您真的知道它们是什么。

#2


27  

This is solved for me when I update maven and check the option "Force update of Snapshots/Releases" in Eclipse. this clears all errors. So right click on project -> Maven -> update project, then check the above option -> Ok. Hope this helps you.

当我更新maven并检查Eclipse中的“快照/发布的强制更新”选项时,这个问题就解决了。清除所有错误。所以右键单击project -> Maven ->更新项目,然后检查上面的选项-> Ok。希望这能帮助你。

#3


19  

It seems like your Maven is unable to connect to Maven repository at http://repo1.maven.org/maven2.

似乎您的Maven无法连接到Maven存储库http://repo1.maven.org/maven2。

If you are using proxy and can access the link with browser the same settings need to be applied to Spring Source Tool Suite (if you are running within suite) or Maven.

如果您正在使用代理,并且可以使用浏览器访问链接,那么需要将相同的设置应用到Spring源工具套件(如果您在套件中运行)或Maven。

For Maven proxy setting create a settings.xml in the .m2 directory with following details

对于Maven代理设置创建一个设置。在.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>

If you are not using proxy and can access the link with browser, remove any proxy settings described above.

如果您没有使用代理,并且可以使用浏览器访问该链接,请删除上面描述的任何代理设置。

#4


5  

For the first error you can simply clear your local repository cache to force it download from main repository rather than checking the local one.

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

For second error, if you are behind proxy you should configure it this way Configuring a proxy otherwise you have a network problem now.

对于第二个错误,如果你是在代理后面,你应该配置它来配置一个代理,否则你现在有一个网络问题。

#5


3  

To me the solution was just deleted the specific folder which is giving the error from ~/.m2/repository/org/hsqldb/

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

After deleting the hsqldb folder I have build the project and everything is fine.

在删除hsqldb文件夹之后,我构建了这个项目,一切都很好。

#6


3  

What helped me were the suggestions by @carlspring (create a settings.xml to configure your http proxy):

@carlspring的建议(创建一个设置)帮助了我。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>

AND then refreshing eclipse project maven as suggested by @Peter T :

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

"Force update of Snapshots/Releases" in Eclipse. this clears all errors. So right click on project -> Maven -> update project, then check the above option -> Ok. Hope this helps you.

“在Eclipse中强制更新快照/发布”。清除所有错误。所以右键单击project -> Maven ->更新项目,然后检查上面的选项-> Ok。希望这能帮助你。

#7


2  

It seems me there was a network issue. On your side, or on Maven side, or anywhere in the middle. Just try again later.

我好像有网络问题。在你这边,或者在Maven边上,或者在中间的任何地方。稍后再试。

If the error is permanent, check your network settings. If you are behind a proxy, you need the following in you ~/.m2/settings.xml:

如果错误是永久性的,请检查您的网络设置。如果你在一个代理后面,你需要在你的~/.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>

#8


2  

I strongly recommend to use a Maven Repository Manager such as Nexus. It will help you to get stable and reproducible builds with Maven. As the Repository Manager is usually in your LAN, you don't have to configure the proxy settings, but you need to define some other configurations:

我强烈建议使用Maven存储库管理器,比如Nexus。它将帮助您获得稳定和可复制的构建与Maven。由于存储库管理器通常在您的LAN中,所以您不必配置代理设置,但是您需要定义一些其他配置:

http://www.sonatype.com/books/nexus-book/reference/maven-sect-single-group.html

http://www.sonatype.com/books/nexus-book/reference/maven-sect-single-group.html

http://maven.apache.org/repository-management.html

http://maven.apache.org/repository-management.html

#9


1  

If none of the above works then try and go this question and answer: Maven error "Failure to transfer..."

如果以上这些都不可行,那么请尝试回答以下问题:Maven错误“传输失败……”

and delete your .lastUpdated files.

并删除您的. lastupdated文件。

#10


1  

I started using maven on my machine first time in while. Got this error: Could not transfer artifact from/to central (https://repo.maven.apache.org/maven2) No such file or directory Cleaned up ~/.m2/repository directory. Don't experience this problem again

我开始在我的机器上第一次使用maven。得到这个错误:不能将工件从/中转移到中心(https://repo.maven.apache.org/maven2),没有这样的文件或目录清理~/。m2 /存储库目录中。不要再体验这个问题了。

#11


1  

  1. Update Maven Project and check the option "Force update of Snapshots/Releases", it will remove errors.
  2. 更新Maven项目并检查“快照/发布的强制更新”选项,它将清除错误。
  3. If not, Maven clean and install the Project.
  4. 如果没有,Maven将清理并安装该项目。
  5. Still the error isn't removed, repeat step 1.
  6. 仍然没有删除错误,重复步骤1。

It worked for me :)

它为我工作:

#12


0  

If you are in windows os and dont need any proxy then delete the whole proxy setting

如果您在windows操作系统中,不需要任何代理,那么就删除整个代理设置。

<proxies>
    <proxy>
   ..................
    </proxy>    
  </proxies> 

and replace with

和替换

<proxies/> 

and then do a maven clean build

然后做一个maven的清洁构建。

#13


0  

This problems was a network issue.

这是一个网络问题。

  1. Go to the local repository and find the directory org/apache/maven/plugins/maven-surefire-plugin.

    转到本地存储库,找到目录org/apache/maven/plugins/maven-surefire-plugin。

  2. Delete the correspond version of it.

    删除相应的版本。

  3. maven update the project, then download it again.

    maven更新项目,然后再次下载。

#14


0  

If you are not behind any proxy and still getting connection timeout error, please check firewall settings/ antivirus. Sometimes firewall may block the connectivity from any tool (like Eclipse/STS etc..)

如果您不支持任何代理,并且仍然有连接超时错误,请检查防火墙设置/反病毒。有时,防火墙可能会阻止任何工具(如Eclipse/STS等)的连接。

#15


0  

We have the Proxy set on company level.

我们有公司级别的代理。

After disabling proxy in Internet Explorer this issue was solved (looks like it is then disabled on 'system' level), so all other browsers will pick this change too.

在Internet Explorer中禁用代理之后,这个问题得到了解决(看起来在系统级别上是禁用的),所以所有其他浏览器也会选择这个更改。

Now I can issue MVN commands from CMD prompt and I have no problem while e.g.

现在我可以在CMD提示符下发出MVN命令,而我没有问题。

"Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-webapp/1.0/maven-archetype-webapp-1.0.pom"

“下载:https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-webapp/1.0/maven-archetype-webapp-1.0.pom”

...that was causing 'Build failure'

…这导致了“构建失败”

Disabling proxy in IE needs to be done on daily basis in our case, because on each system start it gets set

在我们的情况下,在IE中禁用代理需要在日常的基础上完成,因为在每个系统启动时它都会被设置。