Idea Maven错误:was cached in the local repository, resolution will not be reattempted until the update
·
问题及原因
为了学习SpringBoot源码,springboot项目从2.4.5 更改为2.2.1.RELEASE,发现总是无法找到依赖,一开始以为是阿里云上没有这个jar,然后访问阿里云maven仓库发现是存在的,在maven project上点击reimport也无效,于是怀疑是idea的问题,之前maven down源码就出现过无法下载的问题,于是通过Terminal执行mvn compile也不行,但是看到报错原因了
was cached in the local repository, resolution will not be reattempted until the update interval of io.spring.repo.maven.release has elapsed or updates are forced
网路上查找后,发现主要是因为Maven默认会使用本地缓存的库来编译工程,而上次下载的库失败导致的。
解决办法
共有三种方法,以下择一即可,本人用第2个解决的
- 删除~/.m2/repository/对应目录或目录下的*.lastUpdated文件,然后再次运行maven命令
- maven命令后加-U,如mvn package -U ==我是用这个解决的==
- 在repository的release或者snapshots版本中新增updatePolicy属性,其中updatePolicy可以设置为”always”、”daily” (默认)、”interval:XXX” (分钟)或”never”
<repositories> <repository> <id>io.spring.repo.maven.release</id> <url>http://repo.spring.io/release/</url> <releases> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </releases> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories>
更多推荐

所有评论(0)