Maven编译打包时报“PKIX path building failed”异常解决方法
现在用intellij idea集成开发工具的人越来越多,所以今天我也想弄弄这个开发工具。 在编译maven项目的时候报了一个异常,在网上搜了一些文章最终将问题解决了,在此记录下来方便以后查阅。
异常代码如下:
[error] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project Learn_design-pattern: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile failed: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.5.1 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-compiler-plugin:jar:2.5.1 -> org.codehaus.plexus:plexus-compiler-api:jar:1.9.1: Failed to read artifact descriptor for org.codehaus.plexus:plexus-compiler-api:jar:1.9.1: Could not transfer artifact org.codehaus.plexus:plexus-compiler-api:pom:1.9.1 from/to nexus (https://maven.xxx.com/nexus/content/groups/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]
** 主要是这段错误信息: from/to nexus (https://maven.xxx.com/nexus/content/groups/public): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 由于访问"maven.xxx.com"域名时需要安全证书,所以生成一个证书就可以了。
解决方法也很简单:
- 下载InstallCert.java,见附件
- 在命令行下进入InstallCert.java所在文件夹
- 编译InstallCert.java文件,执行InstallCert:

- 执行上图命令后会打出下图信息:

- 输入“1”回车后,会在当前文件夹下生成“jssecacerts”的文件
- 将“jssecacerts”的文件放入JAVA_HOME/jre/lib/security目录下
再进行maven编译就可以了。 **