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.releaseid>
      <url>http://repo.spring.io/release/url>
      <releases>
        <enabled>trueenabled>
        <updatePolicy>alwaysupdatePolicy>
      releases>
      <snapshots><enabled>falseenabled>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

你可能感兴趣的:(#,maven,maven)