Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4 from https://repo.mave

该博客主要讲述Java Maven项目导入Eclipse报错问题,即从Maven中心仓库拉取特定jar包到本地仓库失败且不会重新下载。解决办法是找到本地Maven仓库对应报错目录并删除,然后右键项目选择Maven更新项目,更新后报错消失。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题发生原因:java maven项目导入eclipse报错
问题描述如下

Description	Resource	Path	Location	Type
Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4 
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.
plugins:maven-surefire-plugin:pom:2.12.4 from/to central (https://repo.maven.apache.org/maven2): 
The operation was cancelled.	pom.xml	/data.core	line 1	Maven Configuration Problem

大概意思是:从maven中心仓库拉 maven-surefire-plugin:pom:2.12.4 这个jar包到本地仓库时失败,不会重新下载jar包,除非maven更改索引或强制更新
解决办法:
1.找到本地的maven仓库(具体位置看自己放到哪里,例如:E:\repo)对应报错的目录,例如我的这个报错位置在:
E:\repo\org\apache\maven\plugins\maven-surefire-plugin\2.12.4 删除此目录
2.点击项目右键–>maven–>Update Project
3.更新完后,报错消失

Windows"C:\Program Files\Java\jdk1.8.0_361\bin\java.exe" -Dmaven.multiModuleProjectDirectory=E:\java_dev\apache-tomcat-9.0.22\webapps\xxxx\web-001 -Djansi.passthrough=true -Dmaven.home=C:\Users\hw\.m2\wrapper\dists\apache-maven-3.8.5-bin\5i5jha092a3i37g0paqnfr15e0\apache-maven-3.8.5 -Dclassworlds.conf=C:\Users\hw\.m2\wrapper\dists\apache-maven-3.8.5-bin\5i5jha092a3i37g0paqnfr15e0\apache-maven-3.8.5\bin\m2.conf "-Dmaven.ext.class.path=E:\java_dev\IntelliJ IDEA 2024.1.7\plugins\maven\lib\maven-event-listener.jar" "-javaagent:E:\java_dev\IntelliJ IDEA 2024.1.7\lib\idea_rt.jar=5488:E:\java_dev\IntelliJ IDEA 2024.1.7\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\hw\.m2\wrapper\dists\apache-maven-3.8.5-bin\5i5jha092a3i37g0paqnfr15e0\apache-maven-3.8.5\boot\plexus-classworlds-2.6.0.jar;C:\Users\hw\.m2\wrapper\dists\apache-maven-3.8.5-bin\5i5jha092a3i37g0paqnfr15e0\apache-maven-3.8.5\boot\plexus-classworlds.license org.codehaus.classworlds.Launcher -Didea.version=2024.1.7 deploy [INFO] Scanning for projects... [INFO] [INFO] ------------------------< com.example:web-001 >------------------------- [INFO] Building web-001 1.0-SNAPSHOT [INFO] --------------------------------[ war ]--------------------------------- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ web-001 --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ web-001 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ web-001 --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ web-001 --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ web-001 --- [INFO] [INFO] --- maven-war-plugin:3.3.2:war (default-war) @ web-001 --- [INFO] Packaging webapp [INFO] Assembling webapp [web-001] in [E:\java_dev\apache-tomcat-9.0.22\webapps\xxxx\web-001\target\web-001-1.0-SNAPSHOT] [INFO] Processing war project [INFO] Copying webapp resources [E:\java_dev\apache-tomcat-9.0.22\webapps\xxxx\web-001\src\main\webapp] [INFO] Building war: E:\java_dev\apache-tomcat-9.0.22\webapps\xxxx\web-001\target\web-001-1.0-SNAPSHOT.war [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ web-001 --- [INFO] Installing E:\java_dev\apache-tomcat-9.0.22\webapps\xxxx\web-001\target\web-001-1.0-SNAPSHOT.war to D:\java_dev\Maven\repository\com\example\web-001\1.0-SNAPSHOT\web-001-1.0-SNAPSHOT.war [INFO] Installing E:\java_dev\apache-tomcat-9.0.22\webapps\xxxx\web-001\pom.xml to D:\java_dev\Maven\repository\com\example\web-001\1.0-SNAPSHOT\web-001-1.0-SNAPSHOT.pom [INFO] [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ web-001 --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.651 s [INFO] Finished at: 2025-06-17T09:31:40+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project web-001: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
06-18
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值