Maven 打包报错sun.security.validator.ValidatorException: PKIX path

Posted geekfly

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Maven 打包报错sun.security.validator.ValidatorException: PKIX path相关的知识,希望对你有一定的参考价值。

使用mvn package打包是出现如下错误

[ERROR] Failed to execute goal on project canvas: Could not resolve dependencies for project xxx:xxx:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at org.apache.httpcomponents:httpclient-cache:jar:4.5.6: Failed to read artifact descriptor for org.apache.httpcomponents:httpclient-cache:jar:4.5.6: Could not transfer artifact org.apache.httpcomponents:httpclient-cache:pom:4.5.6 from/to aliyunmaven (https://maven.aliyun.com/repository/public): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [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/DependencyResolutionException

解决办法:

1. 下载证书crt

本地maven仓库改到阿里云了,因此访问报错提到的仓库网址

下载crt证书,保存到桌面

我下载的证书名为:gsorganizationvalsha2g2r1.crt

2. 导入证书

Mac终端执行(注意配置文件位置)

keytool -import -file gsorganizationvalsha2g2r1.crt -keystore $JAVA_HOME/jre/lib/security/cacerts

输入cacerts默认密码: changeit 是否导入输入:y

3. 重新打包

执行:mvn package -Djavax.net.ssl.trustStore=$JAVA_HOME/jre/lib/security/cacerts

以上是关于Maven 打包报错sun.security.validator.ValidatorException: PKIX path的主要内容,如果未能解决你的问题,请参考以下文章

IDEA使用Maven打包Spark项目报错,求大神指点下

升级java11后,maven命令打包报错

Maven打包后运行报错

Maven打包后运行报错

Maven打包后运行报错

spark-maven打包报错