Maven偶现本地仓库jar存在仍然从远程仓库拉取且失败的现象

问题现象

使用Maven过程中,曾经出现过本地仓库中已经存在某jar包,但是Maven仍然从远程仓库下载jar包的现象,并且可能会报出类似以下的错误:

[exec] [ERROR]   The project com.acme:test:0.0.1-SNAPSHOT (/home/acme/pom.xml) has 1 error
[exec] [ERROR]     Non-resolvable parent POM: Failure to find com.acme.maven:parent-pom:pom:2 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at no local POM @ line 5, column 13 -> [Help 2]

解决方案

在stackoverflow看到了类似的问题,可以通过删除_remote.repositories文件解决问题。

Maven使用_remote.repositories文件存储本地jar对应的远程仓库源头。如果源头已经不存在该jar包(比如更改配置切换镜像、切换仓库导致的),Maven的resolve会失败,从而导致项目构建失败。删除了该文件以后,Maven不再从远程仓库执行此操作,因此可以解决问题。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容