分享

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

 hongjing_z 2019-04-08

问题及原因

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

Non-resolvable import POM: Failure to find org.springframework:spring‐framework‐bom:pom:4.3.5.RELEASE in http://repo./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./release/</url>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
      </releases>
      <snapshots><enabled>false</enabled></snapshots>
    </repository>
  </repositories>

参考资源

  1. http:///questions/4856307/when-maven-says-resolution-will-not-be-reattempted-until-the-update-interval-of/41391500#41391500
  2. http://maven./ref/3.3.9/maven-settings/settings.html

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多