参考网址:http://www.mkyong.com/maven/how-to-convert-maven-java-project-to-support-eclipse-ide/

     https://blog.csdn.net/gsycwh/article/details/52792633

问题描述:

在创建Maven项目时,经常会在pom.xml的第一行处报错,提示信息如下:

Failure to transfer org.apache.maven:maven-surefire-plugin:jar: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:maven- operation was cancelled.

问题分析:

  maven的plugin并未下载到本地

解决办法1(优先):

  1.Navigate to your Java project folder, where pom.xml file is placed.

    mvn eclipse:eclipse

     【 如果有错误,会显示错误的原因。】

  2.根据错误原因,你可以到本地库中搜索“.lastUpdated”结尾的文件,找到一份 maven-surefire-plugin-2.7.1.pom.lastUpdated的文件,将其删除。如未自行设置,本地仓库为C:\Users\admin\.m2\repository。

  3. mvn eclipse:eclipse 

    【成功】

解决办法2:

  1. 你可以到本地库中搜索“.lastUpdated”结尾的文件,找到一份 maven-surefire-plugin-2.7.1.pom.lastUpdated的文件,将其删除。如未自行设置,本地仓库为C:\Users\admin\.m2\repository。

  2.回到项目中,在项目右键点击project -> Maven -> Update Dependencies(Update Project…)更新项目,这时候应该就没有错了。

注意:

  1.maven-surefire-plugin-2.7.1.pom.lastUpdated文件不是固定的,而是要看报错的具体信息,如上面错误信息中,主要看报错的maven:后面紧跟的信息

  2.方法一和方法二的区别在于 错误的原因更详细、具体、准确。

 

 

 

相关文章:

  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-10
  • 2021-04-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2021-06-06
相关资源
相似解决方案