文章目录
  1. 1. maven无法更新jar的解决方案

maven无法更新jar的解决方案

原因:
是由于上次运行mvn install 时,jar下载完全,或者老的jar没有删除干净,导致下载新的jar时,有冲突。

I had a related problem, but Raghuram’s answer helped. (I don’t have enough reputation yet to vote his answer up). I’m using Maven bundled with NetBeans, and was getting the same “…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.
To fix this I added <updatePolicy>always</updatePolicy> to my settings file (C:\Program Files\NetBeans 7.0\java\maven\conf\settings.xml)

<profile>
  <id>nexus</id>
  <!--Enable snapshots for the built in central repo to direct -->
  <!--all requests to nexus via the mirror -->
  <repositories>
<repository>
  <id>central</id>
  <url>http://central</url>
  <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
  <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
</repository>
  </repositories>
 <pluginRepositories>
<pluginRepository>
  <id>central</id>
  <url>http://central</url>
  <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
  <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
</pluginRepository>
  </pluginRepositories>
</profile>

或者通过pom.xml配置
pom.xml:

<repositories>
<repository>
<id>alimaven</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
<repository>
<id>archiva.default</id>
<url>http://repository.sonatype.org/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>

<repository>
<id>archiva.3</id>
<url>http://www.mvnrepository.com/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>archiva.5</id>
<url>http://repository.jboss.com/maven2/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>releases</id>
<name>Releases</name>
<url>https://oss.sonatype.org/content/repositories/releases</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>

再次运行mvn clean install 解决。

文章目录
  1. 1. maven无法更新jar的解决方案