Maven error “Failure to transfer…”

问题描述

在import maven project后,执行maven upadte,但是因为速度慢,终止了.
在启动时就出现如下错误.

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/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-compiler-plugin:pom:2.0.2 from/to central (http://repo1.maven.org/maven2): No response received after 60000 ExampleProject Unknown Maven Problem

解决方法一:

右击项目->选择maven->更新项目->选中”强制更新快照或发布”,点击OK.
In Eclipse: Right click the project->Maven->Update Project->Check checkbox “Force Update of Snapshots/Releases”. Click OK.

Force update

解决方法二:

移除下载失败的内容

  • For *nix:

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

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

然后maven更新项目,记得选中更新依赖.
推荐方法一

参考自Stack Overflow