un.security.validator.ValidatorException: PKIX path building failed 异常总结

时间:2024-04-03 09:32:08

ERROR] Failed to execute goal on project esNewsServer: Could not resolve dependencies for project com.esNewsTest:esNewsServer:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at javax.xml.bind:jaxb-api:jar:2.3.0: Failed to read artifact descriptor for javax.xml.bind:jaxb-api:jar:2.3.0: Could not transfer artifact javax.xml.bind:jaxb-api:pom:2.3.0 from/to alimaven (http://maven.aliyun.com/nexus/content/repositories/central/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]

 

问题背景:我当前的JDK为1.8,因1.8不支持jdbc的链接,所有需要在POM文件中中配置下载(jaxb-api、jaxb-impl、jaxb-core,如下面的POM内容)等jar包,在运行过程中报如上的PKIX path building failed的错误提示,根据网上找的资料确认为证书不被信任导致
  

解决办法如下:

一、获取证书:

1、在报错日志中复制链接(http://maven.aliyun.com/nexus/content/repositories/central/);

2、打开谷歌浏览器,粘贴访问。然后如下图点击锁形按钮,点证书;

un.security.validator.ValidatorException: PKIX path building failed 异常总结

3、如下图操作,根据证书导出向导指引导出证书,记住必须选“DER 编码二进制X.509(.CER)”格式,我是以“nexus.content.repositories.central”命名,导到了C:\Users目录下,好记

un.security.validator.ValidatorException: PKIX path building failed 异常总结

二、导入证书到JDK

以管理员身份运行CMD,CD到JDK 1.8所在的“JAVA_HOME/jre/lib/securiy”目录。具体操作如下:

1)、CD C:\Program Files\Java\jre1.8.0_231\lib\security   (路径视你的JDK目录为准) 

2)、然后在命令行输入: keytool -keystore cacerts -importcert -alias nexussecureca -file /Users/nexus.content.repositories.central.cer       回车   (记住:务必带上证书的后缀,否则系统会报错)

3)、根据提示输入**库口令(java的默认口令是changeit),输前注意大小写,因为在输密码的过程中,界面不会有任何的反应,但是后台会记录密码的

un.security.validator.ValidatorException: PKIX path building failed 异常总结

4)、系统会询问“是否信任此证书?”,如下图提示输入“y”即可。

5)、eclipse中,运行生成后就不会报上述异常了