maven中如何处理was cached in the local repository, resolution will not be reattempted until the update
下文笔者讲述maven打包时,出现以下错误提示信息
解决方法2:
was cached in the local repository, resolution will not be reattempted
今天maven打包时,出现以下错误提示:
[ERROR] Failed to execute goal on project xxx: Could not resolve dependencies for project xxx:jar:0.0.1: Failure to find yyy:zzz:jar:1.0.0 in http://xxx:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
那么到底是什么原因呢?
Maven默认会使用本地缓存的库来编译工程
对于上次下载失败的库,maven会在~/.m2/repository/<group>/<artifact>/<version>/目录下创建xxx.lastUpdated文件。
一旦这个文件存在,那么在直到下一次nexus更新之前都不会更新这个依赖库
===========================================================================
处理此类异常的方法,我们只需在打包时候 后面加上 -U参数即可
例
mvn clean package -U
-U参数:
会强制update本地jar(不用再专门去删除)
-U,--update-snapshots :
Forces a check for missing releases and updated snapshots on remote repositories
解决方法2:
删除.lastUpdated文件
然后再次运行 maven打包命令
解决方法3:repository添加updatePolicy属性
使用此方式可强制更新依赖库 如: updatePolicy可以设置为”always”、”daily” (默认)、”interval:XXX” (分钟)或”never” 可在pom.xml的settings.xml中进行相关设置
<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>
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。


