Maven错误:was cached in the local repository, resolution will not be reattempted until the update

问题及原因

今天在测试使用Spring BOM的时候,总发现项目无法打包成功。查看Maven的错误日志发现:

Non-resolvable import POM: Failure to find org.springframework:spring‐framework‐bom:pom:4.3.5.RELEASE in http://repo.spring.io/release/ 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 @ line 29, column 19 -> [Help 2]

随即在StackOverFlow上查看了问题,发现主要是因为Maven默认会使用本地缓存的库来编译工程,而上次下载的库失败导致的。

解决办法

  1. 删除~/.m2/repository/对应目录或目录下的*.lastUpdated文件,然后再次运行maven命令
  2. maven命令后加-U,如mvn package -U
  3. 在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>

参考资源

  1. http://stackoverflow.com/questions/4856307/when-maven-says-resolution-will-not-be-reattempted-until-the-update-interval-of/41391500#41391500
  2. http://maven.apache.org/ref/3.3.9/maven-settings/settings.html
  • 20
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值