maven下载依赖失败:PKIX path building failed

本文解决Maven项目中因证书问题导致的依赖下载失败,提供两种有效方案:一是更新$JAVA_HOME/jre/lib/security/cacerts文件,二是设置Maven忽略SSL证书验证。

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

错误信息:

Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.4.RELEASE:repackage (default) on project mds-all-frontier: Execution default o f goal org.springframework.boot:spring-boot-maven-plugin:2.1.4.RELEASE:repackage failed: Plugin org.springframework.boot:spring-boot-maven-plugin:2.1.4.RELEASE or one of its dependencies could not be resolved: Failed to collect dependencies at org.springframework.boot:spring-boot-maven-plugin:jar:2.1.4.RELEASE -> org.springf ramework.boot:spring-boot-loader-tools:jar:2.1.4.RELEASE: Failed to read artifact descriptor for org.springframework.boot:spring-boot-loader-tools:jar:2.1.4.RELEAS E: Could not transfer artifact org.springframework.boot:spring-boot-loader-tools:pom:2.1.4.RELEASE from/to central (https://repo.maven.apache.org/maven2): sun.secu rity.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path t o requested target

 

两种解决方案:

  1.  将https://repo.maven.apache.org/maven2/和https://maven.aliyun.com/nexus/content/groups/public/ 证书加入$JAVA_HOME\jre\lib\security\cacerts中 (部分有效)

keytool -import -alias maven.aliyun.com -keystore ./cacerts -file code.cer -trustcacerts -storepass changeit 

keytool -import -alias repo.maven.com -keystore ./cacerts -file repo.cer -trustcacerts -storepass changeit 

 

  2. mvn下载依赖忽略SSL证书认证(亲测有效)

-Dmaven.multiModuleProjectDirectory=$MAVEN_HOME -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值