Java Maven 错误 - 传输失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23490556/
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
Maven Error - Failure to Transfer
提问by CarlJohn
I'm looking into some spring examples on net. I got one example from
我正在网上查看一些弹簧示例。我得到了一个例子
http://code.google.com/p/spring-finance-manager/
http://code.google.com/p/spring-finance-manager/
While importing the project in my eclipse,I got error in POM.xml file.
在我的 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
I also tried by deleting my .m2\repository folder. But still getting the error.
我也尝试删除我的 .m2\repository 文件夹。但仍然收到错误。
Can anyone guide me to solve this?
谁能指导我解决这个问题?
回答by Vassilis Blazos
You are getting a timeout exception requesting http://repo.maven.apache.org/maven2repository. Time to time http://repo.maven.apache.org/maven2not working properly. Also possible other network problems, like your hosts dns, network broken hub, network proxy settings etc...
您收到请求http://repo.maven.apache.org/maven2存储库的超时异常。有时 http://repo.maven.apache.org/maven2无法正常工作。也可能存在其他网络问题,例如您的主机 dns、网络损坏的集线器、网络代理设置等...
回答by Sumit Singh
This problem is mostly because of firewall better use proxy.
In your settings.xml
(.m2\repository\settings.xml), add corresponding proxy
settings to tell Maven to go through the proxy to download the artifacts
这个问题主要是因为防火墙更好地使用代理。
在您的settings.xml
(.m2\repository\settings.xml) 中,添加相应proxy
设置以告诉 Maven 通过代理下载工件
<settings>
.......
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>your_proxy_host</host>
<port>your_proxy_port</port>
<!-- Its optional if you need user name and password to connect proxy remove comment.
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>*.yourdomain.com|*.yourOtherDomain.com</nonProxyHosts>
-->
</proxy>
</proxies>
</settings>
回答by Rao Pathangi
Yes, I have experienced this issue myself. Here are a few other observations:
是的,我自己也遇到过这个问题。以下是一些其他观察结果:
- Previously when I had this error, I would go to Maven -> Update Maven Project and if this does not work, Maven -> Update Maven Project and "Force Update of snapshots/releases." This technique would work.
- After a while, #1 above stopped working. However, when I built the same project in the same workspace without the proxy, it worked.
- Applying settings.xml with proxy information does not solve this specific problem stated below:
- 以前,当我遇到此错误时,我会转到 Maven -> 更新 Maven 项目,如果这不起作用,则 Maven -> 更新 Maven 项目和“强制更新快照/发布”。这种技术会奏效。
- 过了一会儿,上面的#1 停止工作。但是,当我在没有代理的情况下在同一个工作区中构建同一个项目时,它起作用了。
- 应用带有代理信息的 settings.xml 并不能解决下面提到的这个特定问题:
Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (http://repo.maven.apache.org/maven2): connect timed out
无法传输工件 org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central ( http://repo.maven.apache.org/maven2):连接超时
I am also wondering what this actually means: what exactly is being transferred and from where to where? I believe we have .pom files initially in our workspaces and based on the pom, the necessary artifacts will be downloaded to our local maven repositories. These repositories are further referred to in our IDE build path.
我还想知道这实际上意味着什么:究竟正在传输什么以及从哪里转移到哪里?我相信我们最初在我们的工作区中有 .pom 文件,并且基于 pom,必要的工件将被下载到我们本地的 maven 存储库。这些存储库在我们的 IDE 构建路径中进一步引用。
Why is it that it "times out" for certain artifacts and not for others? Also, these things seem to point to "org.eclipse.m2.core." To be more precise, the combination of org.eclipse.m2.core and proxy is screwing it up -- which as developers we have no control over. It is very frustrating.
为什么它对某些工件而不是其他工件“超时”?此外,这些东西似乎指向“org.eclipse.m2.core”。更准确地说,org.eclipse.m2.core 和代理的组合正在搞砸——作为开发人员,我们无法控制。这是非常令人沮丧的。
What we do not know can seriously hurt us -- case in point -- (eclipse + proxy) dynamics.
我们不知道的东西会严重伤害我们——例如——(日食+代理)动态。
回答by Rao Pathangi
Figured out the solution after some heavy googling: in addition to adding proxy information in the settings.xml, I also had to add the following to make the problem go away. Once again, this is a problem only when there is a proxy involved. This is the calm before the next eclipse related cryptic stack trace vomit -- I guess.
经过一番繁重的谷歌搜索后找到了解决方案:除了在settings.xml中添加代理信息之外,我还必须添加以下内容才能使问题消失。再一次,只有当涉及代理时,这才是一个问题。这是下一次与日食相关的神秘堆栈跟踪呕吐之前的平静——我猜。
<activeProfiles>
<activeProfile>securecentral</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>securecentral</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
回答by JishBoos
I faced the same issues in many different networks, that's not normally happening because of your internet or network, that's the issue with Maven repo , as a solution I cleaned up my local .m repo directory and download the jar files again via maven / update the maven dependencies. the issue will be gone. and that's just one time process, don't need to do it everytime.
我在许多不同的网络中遇到了同样的问题,这通常不会发生,因为您的互联网或网络,这就是 Maven repo 的问题,作为解决方案,我清理了本地 .m repo 目录并通过 maven / update 再次下载了 jar 文件Maven 依赖项。问题将消失。这只是一次过程,不需要每次都这样做。
回答by Sameer Patel
Provide the settings.xml file for maven which contains userid and password information to connect to the repository. The settings.xml file contains information like this -
为 maven 提供 settings.xml 文件,其中包含用于连接到存储库的用户 ID 和密码信息。settings.xml 文件包含这样的信息 -
<repository>
<id>your_nexus_repo_id</id>
<url>https://path_to_nexus_repo_location</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<server>
<id>dsnexus1</id>
<username>your_user_id</username>
<password>your_password</password>
</server>
You can provide the settings.xml file in Eclipse like this -
您可以像这样在 Eclipse 中提供 settings.xml 文件 -
- In Eclipse IDE, go to Windows >> Preferences >> Maven >> User Settings
- Provide settings.xml in "User Settings" input box by using the Browse Button. Your settings.xml file should be located in /user-home/.m2/ folder.
- 在 Eclipse IDE 中,转到 Windows >> Preferences >> Maven >> User Settings
- 使用浏览按钮在“用户设置”输入框中提供 settings.xml。您的 settings.xml 文件应位于 /user-home/.m2/ 文件夹中。
After this -
在这之后 -
- Right Click on your project
- Go to - Maven >> Update Project
- Click "Force update" so that you will get the latest copies of the snapshot releases
- 右键单击您的项目
- 转到 - Maven >> 更新项目
- 单击“强制更新”,您将获得快照版本的最新副本
Now, Build your project -
现在,构建您的项目 -
- Right click your projet
- Go to Run As >> Maven Build
- Provide Goals: "clean install"
- Click Run
- 右键单击您的项目
- 转到运行方式>> Maven 构建
- 提供目标:“全新安装”
- 点击运行
This should solve your problem :)
这应该可以解决您的问题:)