如何完美解決Maven下載依賴時遇到證書問題(PKIX path building failed: sun.security.provider.certpath

今天用IDEA在打開最近在做的一個項目,想給項目添加一些別的功能,在用 maven 導入依賴的時候遇到了如下的問題:
Could not transfer artifact org.mybatis.spring.boot:mybatis-spring-boot-starter:pom:2.1.1 from/to nexus-aliyun (http://maven.aliyun.com/nexus/content/groups/public): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
1
意思大致是在Java庫中沒有找到 https://maven.aliyun.com/ 的證書
下面是我的 Maven 使用的阿里雲的鏡像庫:
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>


1.用谷歌瀏覽器訪問 https://maven.aliyun.com/nexus/content/groups/public/

2.點擊鏈接前面的小鎖,然後點擊如箭頭所指的證書

3.先點擊詳細信息,再點擊複製到文件

下一步

默認,點擊下一步

4.把證書添加到 Java 信任證書庫
把剛纔下載的 ali.cer 證書放在{java安裝根目錄}jrelibsecurity目錄下

在該目錄下運行命令
在路徑框中輸入 cmd,點擊回車

運行命令 keytool -import -alias cacerts -keystore cacerts -file ali.cer

輸入默認密碼:changeit,這是 Java 中 cacerts 證書庫的默認密碼

輸入 Y,信任此證書,至此,證書導入完成

若提示 keytool 錯誤,大可不必操心,只管往下進行即可
5.重新使用 IDEA 下載 maven 依賴

就可以看到依賴在快速的下載啦~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章