---
title: "Maven编译打包时报“PKIX path building failed”异常解决方法"
author: "truth99"
date: "2014-11-25T22:35:04Z"
tags: []
categories: ["编程语言"]
slug: "maven-pkix-path-building-failed"
draft: false
lastmod: "2017-01-18T16:28:37Z"
id: 2160540
url: "https://truth99.iteye.com/blog/2160540"
---

**<span style="color:blue">
现在用intellij idea集成开发工具的人越来越多，所以今天我也想弄弄这个开发工具。
在编译maven项目的时候报了一个异常，在网上搜了一些文章最终将问题解决了，在此记录下来方便以后查阅。
</span>**

**异常代码如下：**


```java

[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]

```

<span style="color:blue">**
主要是这段错误信息：
**</span>
<span style="color:red">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</span>
<span style="color:blue">**
由于访问"maven.xxx.com"域名时需要安全证书，所以生成一个证书就可以了。

解决方法也很简单：
1. 下载InstallCert.java,见附件
2. 在命令行下进入InstallCert.java所在文件夹
3. 编译InstallCert.java文件，执行InstallCert：
![](http://dl.iteye.com/upload/picture/pic/131915/835d510e-4eb6-30a9-8ee0-f7b73e326fc4.png)
4. 执行上图命令后会打出下图信息：
![](http://dl.iteye.com/upload/picture/pic/131917/c322deef-5af9-3c9b-a516-1c175f469ad0.png)
5. 输入“1”回车后，会在当前文件夹下生成“jssecacerts”的文件
6. 将“jssecacerts”的文件放入JAVA_HOME/jre/lib/security目录下

再进行maven编译就可以了。
**</span>