[总结]maven 无法下载依赖jar包问题排查

maven 无法下载依赖jar包问题排查

 

1.离线模式导致

IDE编辑器配置了offline mode 模式(离线模式)导致,具体错误信息如下;

 

  • Could not resolve dependencies for project com.xxx:yyy:jar:0.0.1-SNAPSHOT: Cannot access central (https://xxxxx:2888/maven2) in offline mode and the artifact com.zzz:ooo-pp:jar:4.0 has not been downloaded from it before. -> [Help 1]
  •  
  • 解决方法:preferences > Build,Execution,Deployment > Build Tools > Maven > work offline 将该选项前面的勾去掉。不适用离线模式。

《[总结]maven 无法下载依赖jar包问题排查》

 

 

  • 案例:
    • 有一次帮一个开发同事排查问题时,他反馈远程仓库有他要的包,他本地也有,但是他用idea执行package的时候,一直报下载不到jar包,检查了网络,maven setting.xml 项目pom.xml, 各种地方都检查过了。都正确的,但就是无法下载到依赖。
    • 于是我们认真分析了错误信息, in offline mode 最终将焦点集中在这三个单词上。看起来是离线模式什么的鬼东西在作祟。
    • 于是我尝试去百度下idea设置in offline mode的方式,果然打开同事的idea配置,他确实选中了该选项。

 

2.网络下载失败

网络不好,导致第一次下载时下载到中途,因某些原因导致无法继续完整下载。后续再编译的时候,由于本地仓库已经有了该包的基本信息(_remote.repositories,maven-metadata-dev.xml,resolver-status.properties)经过比对这些基本信息后,发现本地和远程的包是相同的,则不会去远程下载。

但同时本地的包由于没有下载完全,也是不可用的。这时候,就只能到~/.m2/repository/your-jar-dir 下手动删除该包,强制本地maven从远程再次下载最新的。

具体详细错误信息如下:

 

Failure to find com.xx.yyy:demo-test:jar:2.6 in http://xxxxx:2888/nexus/content/groups/public was cached in the local repository, 

resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced

 

解决方法:到 ~/.m2/repository/your-jar-dir 目录下手动删除该包

 

3.仓库中根本就没有这个包

 

    原文作者:常乐_smile
    原文地址: https://blog.csdn.net/li396864285/article/details/81168648
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞