maven 打包失败

2018-10-30  本文已影响9人  夜空最亮的9星

问题及原因
今天在测试使用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默认会使用本地缓存的库来编译工程,而上次下载的库失败导致的。

解决办法

删除~/.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>
 

参考资源

http://stackoverflow.com/questions/4856307/when-maven-says-resolution-will-not-be-reattempted-until-the-update-interval-of/41391500#41391500

http://maven.apache.org/ref/3.3.9/maven-settings/settings.html


原文链接

上一篇 下一篇

猜你喜欢

热点阅读