Java Maven 全新安装失败,连接超时:连接错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28725195/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 06:41:47  来源:igfitidea点击:

Maven clean install fails with connection timed out:connect error

javamaven-2pom.xmlconnection-timeout

提问by user3393658

I tried maven clean install on my project and I every time I get the following error

我在我的项目上尝试了 maven clean install,每次出现以下错误时

Maven version 2.2.1 JDK 1.7

Maven 版本 2.2.1 JDK 1.7

F:\Wealth>"C:\Program Files\apache-maven-2.2.1\bin\mvn.bat" cl
ean install -U
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building polo
[INFO]    task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
Downloading: http://maven.apps.com/maven2/org/apache/maven/plugins/maven-cle
an-plugin/2.2/maven-clean-plugin-2.2.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-clean-plugin:pom:2.2' from repository nunki (http://maven.apps.com/maven2): Error transferring file: Connection timed out: connect
Downloading: http://maven.apps.com/maven/org.apache.maven.plugins/poms/maven
-clean-plugin-2.2.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-clean-plugin:pom:2.2' from repository nunki-legacy (http://maven.apps.com/maven): Error transferring file: Connection timed out: connect
Downloading: http://maven.apps.com/maven2//org/apache/maven/plugins/maven-clean-plugin/2.2/maven-clean-plugin-2.2.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-clean-plugin:pom:2.2' from repository central (http://repo1.maven.org/maven2): Error transferring file: Connection timed out: connect
Downloading: http://maven.apps.com/maven2/org/apache/maven/plugins/maven-cle
an-plugin/2.2/maven-clean-plugin-2.2.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-clean-plugin:pom:2.2' from repository nunki (http://maven.apps.com/maven2): Error transferring file: Connection timed out: connect
Downloading: http://maven.apps.com/maven/org.apache.maven.plugins/poms/maven
-clean-plugin-2.2.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-clean-plugin:pom:2.2' from repository nunki-legacy (http://maven.apps.com/maven): Error transferring file: Connection timed out: connect
Downloading: http://maven.apps.com/maven2//org/apache/maven/plugins/maven-cl
ean-plugin/2.2/maven-clean-plugin-2.2.pom
[WARNING] Unable to get resource 'org.apache.maven.plugins:maven-clean-plugin:pom:2.2' from repository central (http://repo1.maven.org/maven2): Error transferring file: Connection timed out: connect
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: org.apache.maven.plugins:maven-clean-plugin

Reason: POM 'org.apache.maven.plugins:maven-clean-plugin' not found in repository: Unable to download the artifact from any repository

  org.apache.maven.plugins:maven-clean-plugin:pom:2.2

from the specified remote repositories:
  nunki-legacy (http://maven.apps.com/maven),
  central (http://maven.apps.com/maven2/),
  nunki (http://maven.apps.com/maven2)

 for project org.apache.maven.plugins:maven-clean-plugin

I have checked the proxy settings in settings.xml and I my feeling is that's the problem. But I have tried the same proxy settings to build other open source software projects and the build was success. But for this project, I see this error.

我检查了 settings.xml 中的代理设置,我觉得这就是问题所在。但是我尝试了相同的代理设置来构建其他开源软件项目并且构建成功。但是对于这个项目,我看到了这个错误。

Can someone give an idea on this problem.

有人可以就这个问题给出一个想法。

回答by P-a B?ckstr?m

Your remote repositories all have the domain maven.apps.com, is that a domain in your intranet? Is Nexus running as a mirror for Maven central?

你的远程仓库都有域maven.apps.com,那是你内网的域吗?Nexus 是否作为 Maven 中心的镜像运行?

If not, you can try removing settings.xml temporarily and see if the default settings succeed.

如果没有,您可以尝试暂时删除settings.xml,看看默认设置是否成功。

回答by naXa

DependencyResolutionException

依赖解决异常

(source: Maven Confluence)

(来源:Maven Confluence

This error generally occurs when Maven could not download dependencies. Possible causes for this error are:

当Maven无法下载依赖项时,通常会出现此错误。此错误的可能原因是:

  1. The POM misses the declaration of the <repository>which hosts the artifact.
  2. The repository you have configured requires authentication and Maven failed to provide the correct credentials to the server. In this case, make sure your ${user.home}/.m2/settings.xmlcontains a <server>declaration whose <id>matches the <id>of the remote repository to use. See the Maven Settings Referencefor more details.
  3. The remote repository in question uses SSL and the JVM running Maven does not trust the certificate of the server.
  4. There is a general network problem that prevents Maven from accessing any remote repository, e.g. a missing proxy configuration.
  5. You have configured Maven to perform strict checksum validation and the files to download got corrupted.
  6. Maven failed to save the files to your local repository, see LocalRepositoryNotAccessibleExceptionfor more details.
  7. In Maven 3 if you just had a failed download and have fixed it (e.g. by uploading the jar to a repository) it will cache the failure. To force a refresh add -Uto the command line.
  1. POM 错过了<repository>托管工件的声明。
  2. 您配置的存储库需要身份验证,而 Maven 未能向服务器提供正确的凭据。在这种情况下,请确保您${user.home}/.m2/settings.xml包含的<server>声明<id><id>要使用的远程存储库的相匹配。有关更多详细信息,请参阅Maven 设置参考
  3. 有问题的远程存储库使用 SSL,运行 Maven 的 JVM 不信任服务器的证书。
  4. 存在阻止 Maven 访问任何远程存储库的一般网络问题,例如缺少代理配置。
  5. 您已将 Maven 配置为执行严格的校验和验证,但要下载的文件已损坏。
  6. Maven 未能将文件保存到您的本地存储库,请参阅LocalRepositoryNotAccessibleException了解更多详细信息。
  7. 在 Maven 3 中,如果您刚刚下载失败并已修复它(例如,通过将 jar 上传到存储库),它将缓存失败。要强制刷新添加-U到命令行。

In case of a general network-related problem, you could also consult the following articles:

如果遇到一般的网络相关问题,您还可以参考以下文章:

回答by Lubo Kanev

I had this problem, where maven couldn't download anything. After some googling and some luck, I deleted the file ~/.m2/server.xml. That fixed the problem. I haven't touched that file before, not sure what the problem was.

我遇到了这个问题,maven 无法下载任何东西。经过一些谷歌搜索和一些运气,我删除了文件 ~/.m2/server.xml。这解决了问题。我以前没有碰过那个文件,不知道是什么问题。