众所周知,Maven在下载仓库中找不到相应资源时,会生成一个.lastUpdated为后缀的文件。如果这个文件存在,那么即使换一个有资源的仓库后,Maven依然不会去下载新资源。除了网上所说的在参数中加入-U以外,本文还提供另外一种方法,可以使大家不用删除.lastUpdated文件的情况下,让Maven去查找最新资源。
正常情况下,我们是把仓库地址配置在settings.xml文件中的mirror节点下,这时如果生成了.lastUpdated文件,默认Maven是不会去取最新资源,但是如果我们把仓库资源配置在settings.xml的<profile>节点中,而不是mirror节点,那么即使更新失败,下一次同步也会忽略这些文件(注意:本人对Maven研究还很浅薄,不清楚使用profile配置仓库和使用mirror到底有什么区别和影响,这里仅仅列出此方法,在没有把握的情况下不推荐大家使用)。
<profile>配置如下:
[html] view plain copy print ? <profiles> <profile> <id>dev<id> <!-- 这个id要和activeProfile里的id一样 --> <repositories> <repository> <id>Nexus</id> <url>http://192.168.9.91:8084/nexus/content/groups/futuresoftware</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile> </profiles> <activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles>
原文地址:http://blog.csdn.net/zhu19774279/article/details/8563796