Maven错误 – 无法转移

我在网上看一些spring的例子。 我有一个例子

http://code.google.com/p/spring-finance-manager/

在我的eclipse中导入项目时,我在POM.xml文件中出错。

Multiple annotations found at this line: - Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from http://repo.maven.apache.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-resources-plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): null to http:// repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom - connection timed out - Failure to transfer org.apache.maven.plugins:maven-source-plugin:pom:2.0.4 from http://repo.maven.apache.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-source-plugin:pom:2.0.4 from/to central (http://repo.maven.apache.org/maven2): connection timed out to http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-source-plugin/2.0.4/maven-source-plugin-2.0.4.pom 

我还尝试删除我的.m2 \ repository文件夹。 但仍然得到错误。

谁能指导我解决这个问题?

是的,我自己也遇到过这个问题。 以下是其他一些观察结果:

  1. 以前当我遇到这个错误时,我会去Maven – >更新Maven项目,如果这不起作用,Maven – >更新Maven项目和“强制更新快照/发布”。 这种技术可行。
  2. 过了一会儿,上面的#1停止了工作。 但是,当我在没有代理的同一工作区中构建相同的项目时,它工作。
  3. 将settings.xml与代理信息一起使用并不能解决以下所述的特定问题:

无法传输工件org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from / to central( http://repo.maven.apache.org/maven2 ):connect timed out

我也想知道这实际意味着什么:究竟是什么转移以及从哪里到哪里? 我相信我们最初在工作区中有.pom文件,并且基于pom,必要的工件将被下载到我们的本地maven存储库。 这些存储库在我们的IDE构建路径中进一步引用。

为什么某些工件“超时”而不是其他工件? 而且,这些东西似乎指向“org.eclipse.m2.core”。 更确切地说,org.eclipse.m2.core和代理的组合正在搞砸它 – 作为开发人员我们无法控制。 这非常令人沮丧。

我们不知道的可能会严重伤害我们 – 例如 – (日食+代理)动态。

在一些沉重的谷歌搜索之后找出解决方案:除了在settings.xml中添加代理信息之外,我还必须添加以下内容以使问题消失。 再一次,只有涉及代理时才会出现问题。 这是在下一次日食相关的神秘堆栈痕迹呕吐之前的平静 – 我想。

   securecentral    securecentral   central https://repo1.maven.org/maven2  true      central https://repo1.maven.org/maven2  true      

您正在获取请求http://repo.maven.apache.org/maven2存储库的超时exception。 时不时地http://repo.maven.apache.org/maven2无法正常工作。 也可能是其他网络问题,如主机DNS,网络中断集线器,网络代理设置等…

我在许多不同的网络中遇到了同样的问题,这通常不会因为您的互联网或网络而发生,这是Maven repo的问题,作为解决方案我清理了我的本地.m repo目录并通过maven / update再次下载了jar文件maven依赖。 问题将消失。 这只是一次性过程,不需要每次都这样做。

为maven提供settings.xml文件,其中包含用于连接到存储库的用户标识和密码信息。 settings.xml文件包含这样的信息 –

  your_nexus_repo_id https://path_to_nexus_repo_location  true   true    dsnexus1 your_user_id your_password  

您可以在Eclipse中提供settings.xml文件,如下所示 –

  1. 在Eclipse IDE中,转到Windows >>首选项>> Maven >>用户设置
  2. 使用“浏览”按钮在“用户设置”输入框中提供settings.xml。 您的settings.xml文件应位于/user-home/.m2/文件夹中。

在这之后 –

  1. 右键单击您的项目
  2. 转到 – Maven >>更新项目
  3. 单击“强制更新”,以便获取快照版本的最新副本

现在,建立你的项目 –

  1. 右键单击您的项目
  2. 转到运行方式>> Maven Build
  3. 提供目标:“干净安装”
  4. 单击运行

这应该解决你的问题:)

这个问题主要是因为防火墙更好地使用代理。
在您的settings.xml (.m2 \ repository \ settings.xml)中,添加相应的proxy设置以告知Maven通过代理下载工件

  .......   true http your_proxy_host your_proxy_port