真正解决Could not transfer artifact org.springframework.bootspring-boot-starter-parentpom

解决新建springboot项目时包导不进来的问题

发现问题

  • 新建一个springboot项目
  • 此时maven的setting配置文件配置的阿里云的源
  • 发现很多包导不进来,于是reimport,没有效果
  • 于是执行clean命令
  • 报错

Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.4.RELEASE from/to alimaven (https://maven.aliyun.com/repository/central): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

  • 进入报错的网站查找springbootRELEASE2.2.4的包(https://maven.aliyun.com/repository/central)
    在这里插入图片描述
  • 发现阿里云还没有2.2.4的包,于是将springboot的版本改成2.1.7
    在这里插入图片描述
  • 还是报错
  • 查看报错信息的后半部分

( sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target)
无法找到有效的证书

  • 找到问题所在

解决问题(两种方法)

第一种方法:在执行maven命令时忽略证书检查

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

  • 在此处设置忽略证书检查
    在这里插入图片描述

  • 命令如下

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

第二种方法:手动导入证书

  • 确保maven中setting文件中的阿里源配置正确 (注意url中协议为https!)

    nexus-aliyun central Nexus aliyun https://maven.aliyun.com/nexus/content/groups/public
  • 将阿里镜像库的证书加到信任证书库里面

  • 打开上面阿里源的网址

  • 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 FilesJavajre1.8.0_171libsecuritycarcerts

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

总结

这是非常坑人的地方,没有正确的解决问题会让人十分抓狂
希望踩过的坑及时将它填上

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值