eclipse Maven 错误“无法传输...”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5074063/
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-09-10 19:57:54  来源:igfitidea点击:

Maven error "Failure to transfer..."

eclipsemaven

提问by Deepak Joy

I am trying to set up a project using Maven (m2eclipse), but I get this error in Eclipse:

我正在尝试使用 Maven (m2eclipse) 设置一个项目,但在 Eclipse 中出现此错误:

Description Resource Path Location Type Could not calculate build plan: Failure to transfer org.apache.maven.plugins:maven-compiler-plugin:pom:2.0.2 from http://repo1.maven.org/maven2was 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-compiler-plugin:pom:2.0.2 from/to central (http://repo1.maven.org/maven2): No response received after 60000 ExampleProject Unknown Maven Problem

描述资源路径位置类型无法计算构建计划:无法从http://repo1.maven.org/maven2传输 org.apache.maven.plugins:maven-compiler-plugin:pom:2.0.2 was cached in local存储库,直到 central 的更新间隔已过或强制更新,才会重新尝试解析。原始错误:无法传输工件 org.apache.maven.plugins:maven-compiler-plugin:pom:2.0.2 from/to central ( http://repo1.maven.org/maven2):60000ExampleProject 后未收到响应未知的 Maven 问题

Any ideas? It would be helpful if you could show me how to check if everything is configured fine...

有任何想法吗?如果您能告诉我如何检查一切是否配置正常,那将会很有帮助...

回答by Jonas Andersson

Remove all your failed downloads:

删除所有失败的下载:

find ~/.m2  -name "*.lastUpdated" -exec grep -q "Could not transfer" {} \; -print -exec rm {} \;

For windows:

对于窗户:

cd %userprofile%\.m2\repository
for /r %i in (*.lastUpdated) do del %i

Then rightclick on your project in eclipse and choose Maven->"Update Project ...", make sure "Update Dependencies" is checked in the resulting dialog and click OK.

然后在 Eclipse 中右键单击您的项目并选择 Maven->“更新项目...”,确保在结果对话框中选中“更新依赖项”并单击“确定”。

回答by iowatiger08

This worked for me in Windows as well.

这在 Windows 中也对我有用。

  1. Locate the {user}/.m2/repository (Using Juno /Win7 here)
  2. In the Search field in upper right of window, type ".lastupdated". Windows will look through all subfolders for these files in the directory. (I did not look through cache.)
  3. Remove them by Right-click > Delete (I kept all of the lastupdated.properties).
  4. Then go back into Eclipse, Right-click on the project and select Maven > Update Project. I selected to "Force Update of Snapshots/Releases". Click Ok and the dependencies finally resolved correctly.
  1. 找到 {user}/.m2/repository(此处使用 Juno /Win7)
  2. 在窗口右上角的搜索字段中,键入“.lastupdated”。Windows 将在目录中查找这些文件的所有子文件夹。(我没有查看缓存。)
  3. 通过右键单击 > 删除来删除它们(我保留了所有 lastupdated.properties)。
  4. 然后返回 Eclipse,右键单击该项目并选择 Maven > Update Project。我选择了“强制更新快照/版本”。单击确定,依赖项最终正确解析。

回答by Zhenya

In Eclipse: Right click the project->Maven->Update Project->Check checkbox "Force Update of Snapshots/Releases". Click OK.

在 Eclipse 中:右键单击项目->Maven->更新项目->选中复选框“强制更新快照/发布”。单击确定。

回答by Deepak Joy

Thanks for the replies, but after some more searching I was able to fix the problem. It turned out that I had to remove one of the "*.lastUpdated" which was preventing one of my plugins (Maven Surefire Plugin) from updating. I did this manually, because a maven clean wasn't doing it apparently.

感谢您的回复,但经过更多搜索后,我能够解决问题。事实证明,我不得不删除“*.lastUpdated”之一,它阻止了我的一个插件(Maven Surefire Plugin)更新。我手动执行此操作,因为 maven clean 显然没有执行此操作。

The problem was that the "*.lastUpdated" file for a plugin was blocking the maven check for updates and not allowing a necessary jar to get downloaded.

问题是插件的“*.lastUpdated”文件阻止了 maven 检查更新,并且不允许下载必要的 jar。

回答by Lev Khomich

Try to execute

尝试执行

mvn -U clean

or Run > Maven Clean and Maven > Update snapshots from project context menu in eclipse

或 Run > Maven Clean and Maven > Update snapshots from project context menu in eclipse

回答by huan le

In my case. The issues is same reason. I see the problem is on proxy and firewall.

就我而言。问题是同样的原因。我看到问题出在代理和防火墙上。

Here my solution
Fisrt ways:
1. install Proxy for Maven and Eclipse
2. Go to Locate the {user}/.m2/repositoryand Remove all the *.lastupdatedfiles
3. Go back into Eclipse, Right-click on the project and select Maven > Update Project. > Select "Force Update of Snapshots/Releases".

这是我的解决方案
Fisrt 方法:
1. 为 Maven 和 Eclipse 安装代理
2. 找到{user}/.m2/repository并删除所有*.lastupdated文件
3. 返回 Eclipse,右键单击项目并选择Maven > 更新项目。> 选择“强制更新快照/版本”。

If the project is still exist error. example: here is my issues after all above step

如果项目仍然存在错误。示例:这是我在所有上述步骤之后的问题

Failure to transfer org.apache.maven:maven-archiver:pom:2.5 from https://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:maven-archiver:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Connect timed out

I use this solution useful for me:
1. Find repository in https://mvnrepository.com/
2. Copy dependency to my *.pomlof project
example

我使用这个对我有用的解决方案:
1. 在https://mvnrepository.com/ 中查找存储库
2. 将依赖项复制到我的*.poml项目
示例

<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-archiver</artifactId>
    <version>2.5</version>
</dependency>


3. Build project. the dependency missing will be downloaded to local repository.
4. Go back into Eclipse, Right-click on the project and select Maven > Update Project. > Select "Force Update of Snapshots/Releases".
=>> Error is resolved
5. I remove dependencies at step 2 after finished and resolved. Done


3. 构建项目。缺少的依赖项将下载到本地存储库。
4. 返回 Eclipse,右键单击项目并选择Maven > Update Project。> 选择“强制更新快照/版本”。
=>> 错误已解决
5. 完成并解决后,我在步骤 2 中删除了依赖项。完毕

回答by sumeet kumar

This worked for me in Windows:

这在 Windows 中对我有用:

  1. Locate the {user}/.m2/repository
  2. In the Search field in upper right of window, type ".lastupdated". Windows will look through all subfolders for these files in the directory.
  3. Remove all the .lastupdatedfiles.
  4. Go back into Eclipse, Right-click on the project and select Maven > Update Project.
  5. Select "Force Update of Snapshots/Releases".
  6. Click Ok and the dependencies will finally resolve correctly.
  1. 找到 {user}/.m2/repository
  2. 在窗口右上角的搜索字段中,键入“ .lastupdated”。Windows 将在目录中查找这些文件的所有子文件夹。
  3. 删除所有.lastupdated文件。
  4. 返回 Eclipse,右键单击项目并选择Maven > Update Project.
  5. 选择“ Force Update of Snapshots/Releases”。
  6. 单击“确定”,依赖项将最终正确解析。

回答by Kran

It happened to me as Iam behind a firewall. The dependencies doesn't get downloaded sometimes when you are running in Eclipse IDE. Make sure you use mvn clean install -Uto resolve the problem. You would see the dependencies download after this.

它发生在我身上,因为我在防火墙后面。当您在 Eclipse IDE 中运行时,有时不会下载依赖项。确保您使用mvn clean install -U来解决问题。在此之后,您将看到依赖项下载。

回答by Abel Morelos

If you are behind a proxy, you have to update the settings.xml file (under the conf folder of your MAVEN_HOME, the file itself contains information about the proxy settings) and additionally you may need to update your Eclipse Network Settings (Window->Preferences...-> type Network Connections).

如果您使用代理,则必须更新 settings.xml 文件(在 MAVEN_HOME 的 conf 文件夹下,该文件本身包含有关代理设置的信息),此外您可能需要更新 Eclipse 网络设置(窗口->首选项...-> 输入网络连接)。

Try using -X or --debug in order to get the debug output, this could provide additional information about the problem.

尝试使用 -X 或 --debug 以获得调试输出,这可以提供有关问题的其他信息。

回答by Luki

I had similar issue in Eclipse 3.6 with m2eclipse.

我在使用 m2eclipse 的 Eclipse 3.6 中遇到了类似的问题。

Could not calculate build plan: Failure to transfer org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 from http://repo1.maven.org/maven2was 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:jar:2.4.3 from central (http://repo1.maven.org/maven2): ConnectException project1 Unknown Maven Problem

无法计算构建计划:从http://repo1.maven.org/maven2传输 org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 失败被缓存在本地存储库中,解析不会重新尝试直到 Central 的更新间隔已过或强制更新。原始错误:无法从中央 (http://repo1.maven.org/maven2) 传输工件 org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3: ConnectException project1 Unknown Maven Problem

Deleting all maven*.lastUpdated files from my local reository (as Deepak Joy suggested) solved that problem.

从我的本地资源库中删除所有 maven*.lastUpdated 文件(正如 Deepak Joy 建议的那样)解决了这个问题。