之前遇到此类问题都是通过JDK keytool工具添加对应的maven仓库的ssl证书。
国内因网络原因,大部使用的都是阿里的maven仓库。https协议。
报错内容如下:
Could not transfer artifact org.apache.maven.surefire:surefire-booter:pom:2.12.4 from/to alimaven (https://maven.aliyun.com/repository/central/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
如果不添加证书,那就通过忽略证书的方案来解决此问题,有两种方式,如下:
IntelliJ IDEA
如下图,在VM Options中添加参数:
-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true
保存后即可生效,再次打包成功。
VM Options
既然是虚拟机的参数,那我们就可以给vm设置一个全局参数,而上面的方式只针对当前项目有效。
Help→Edit Custom VM Options... 在文件末尾添加如下内容,保存关闭文件,重启IDEA,即可生效
-Dmaven.wagon.http.ssl.insecure=true
-Dmaven.wagon.http.ssl.allowall=true
如果文章解决了你的问题。还请不要吝啬你的点赞哦!让更多的人可以看见。