Maven导包报错Could not resolve dependencies for projectXXX was cached in the local repository....

问题

将项目和maven仓库一起拿到了内网环境,一直报错无法解析依赖was cached in the local repository, resolution
will not be reattempted until the update interval of public has elapsed or updates are forced

解决办法

删除复制过来的maven仓库文件夹中所有的_remote.repositories文件。
这里提供了一个cmd命令批量删除:
进入仓库目录后运行cmd

for /r %i in (_remote.repositories)do del %i

_remote.repositories文件

构成

例如:

#Thu Jan 24 11:42:29 CST 2019
logback-parent-1.1.1.pom>nexus-aliyun=
logback-parent-1.1.1.pom>nexus-xx=
logback-parent-1.1.1.pom>mirror-all=
这里的nexus-aliyun表示setting.xml中配置的私服id
其中
这个文件存储的是每次从私服或者中央仓库下载的jar包的信息。
该logback-parent只有pom管理,所以没有jar

第3行:表示该pom第一次从nexus-aliyun(阿里云镜像)来的

第4行:表示更换远程仓库nexus-xx(xx私服)且该私服存在该pom,那么就将该私服地址写入到_remote.repositories.

第5行:表示镜像服务器mirror-all存在该pom

只有存在该资源的镜像或私服才会将私服或镜像的id写入到_remote.repositories中

作用

maven3.x版本在从远程仓库下载资源后,会生成对应的_remote.repositories文件,标示该资源的来源,如果你有这个文件_remote.repositories,那就不会访问本地了,必须远程上有才行,否则就会报错。

参考资料:https://blog.csdn.net/zzb5682119/article/details/89217780

https://www.freesion.com/article/1964188965/

posted @ 2024-07-30 15:30  日报初级开发工程师  阅读(39)  评论(0)    收藏  举报  来源