解决偶然由于网络故障导致的不更新SNAPSHOT [WARNING] Could not transfer metadata ***:1.0-SNAPSHOT/maven-metadata.xml

原构建指令

mvn clean package -Dmaven.test.skip=true -U

偶尔会构建报警告,不更新SNAPSHOT

[WARNING] Could not transfer metadata ***:1.0-SNAPSHOT/maven-metadata.xml from/to nexus-hknaruto (http://nexus.xxx.com:8081/nexus/content/groups/public): Connect to nexus.xxx.com:8081 [nexus.xxx.com/47.92.147.70] failed: Connection refused (Connection refused)
[WARNING] Failure to transfer com.hknaruto.xxxcenter:xxx-center-dao:1.0-SNAPSHOT/maven-metadata.xml from http://nexus.xxx.com:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus-hknaruto has elapsed or updates are forced. Original error: Could not transfer metadata com.hknaruto.xxxcenter:xxx-center-dao:1.0-SNAPSHOT/maven-metadata.xml from/to nexus-hknaruto (http://nexus.xxx.com:8081/nexus/content/groups/public): Connect to nexus.xxx.com:8081 [nexus.xxx.com/47.92.147.70] failed: Connection refused (Connection refused)
Downloading: http://nexus.xxx.com:8081/nexus/content/groups/public/com/hknaruto/xxxcenter/xxx-center-common/1.0-SNAPSHOT/maven-metadata.xml

导致没有拉取到最新SNAPSHOT库,程序逻辑未按预期执行

 

调整构建指令,构建前删除所有SNAPSHOT库

find ~/.m2/repository -type d | grep SNAPSHOT | xargs -i rm -rf {}
mvn clean package -Dmaven.test.skip=true -U

由于删除了本地SNAPSHOT库所有文件,maven会强制更新下来。

你可能感兴趣的:(maven)