PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

问题截图:无法找到请求目标的有效证书路径

 

 

 

 

 

 jar包更新失败:.lastUpdated

 

报错信息

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:1.0 from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0
Could not transfer artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 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
Could not transfer artifact org.apache.maven.archetypes:maven

 

本人使用的maven版本:3.8.4

 

解决思路1:maven clean -> maven : update preject

解决思路2:重新配置maven

解决思路3:忽略证书 -> 在Eclipse的Maven设置里将Global checksum policy从default设置成ignore就可以关闭这个校验:

 

 

 

解决思路4:在执行maven命令时忽略证书检查

在新建maven工程时,会自执行maven的各种命令

在此处设置忽略证书检查

 

 

 

-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true

  

解决思路5:手动导入证书

  • 确保maven中setting文件中的阿里源配置正确 (注意url中协议为https!)
  • 将阿里镜像库的证书加到信任证书库里面
  • 打开上面阿里源的网址
  • https://maven.aliyun.com/nexus/content/groups/public或https://maven.aliyun.com/repository/central都是一样的
  • 通过chrome浏览器下载证书到本地
  • 打开上面阿里源的网址

 

 

 

  • 一路next,将文件命名为ali_maven,后缀默认为.cer,保存到D盘根目录

  • 通过证书添加到java信任证书库

 

cacerts包含了很多CA证书,位置在Java的安装目录:如: C:\Program Files\Java17\lib\security\carcerts

  

  • 以管理员身份打开命令提示符(cmd)
  • 进入carcerts所在文件目录
  • 执行命令keytool -import -alias cacerts -keystore cacerts -file d:\ali_maven.cer
  • 默认密钥库口令:changeit
  • 是否信任此证书?[否]: Y
  • 显示证书已添加到密钥库中即表示添加成功
  • 回到项目中重新clean,compile,解决

注:以前方案并未解决我的问题,我以为自己把电脑环境搞坏了,又重新装系统又试了,出现如下问题

储存库的镜像被封

Non-resolvable parent POM for com.beyondsoft.sabg.ImagingBiosen:server:0.0.1-SNAPSHOT: 
 org.springframework.boot:spring-boot-starter-parent:pom:2.4.4 failed to transfer from http://0.0.0.0/ 
 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted 
 until the update interval of maven-default-http-blocker has elapsed or updates are forced. Original error: 
 Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.4.4 from/to maven-
 default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [maven-default-http-blocker (http://
 0.0.0.0/, default, releases)]

 

最终解决思路6:降低Maven 版本到3.8.1 以下

 

https://blog.csdn.net/hadues/article/details/119038072

 

posted @ 2022-01-08 20:45  小墨di  阅读(4555)  评论(0编辑  收藏  举报