maven编译报错 was cached in the local repository 拉包失败

Posted 阿拉的梦想

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了maven编译报错 was cached in the local repository 拉包失败相关的知识,希望对你有一定的参考价值。

maven编译报错 was cached in the local repository 拉包失败

报错

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-M3:repackage (default) on project otpweb: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-M3:repackage failed: Plugin org.springframework.boot:spring-boot-maven-plugin:3.0.0-M3 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.springframework:spring-aop:jar:6.0.0-M4, org.springframework.boot:spring-boot-buildpack-platform:jar:3.0.0-M3: Failure to find org.springframework:spring-aop:jar:6.0.0-M4 in http://nexus3.msxf.com/repository/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus3 has elapsed or updates are forced -> [Help 1]

主要是因为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>

以上是关于maven编译报错 was cached in the local repository 拉包失败的主要内容,如果未能解决你的问题,请参考以下文章