When maven says “resolution will not be reattempte

2019-01-01 08:15发布

With maven, I occasionally hit an artifact that comes from some 3rd-party repo that I haven't built or included in my repository yet.

I'll get an error message from the maven client saying that an artifact can't be found:

Failure to find org.jfrog.maven.annomojo:maven-plugin-anno:jar:1.4.0 in http://myrepo:80/artifactory/repo was cached in the local repository, resolution will not be reattempted until the update interval of MyRepo has elapsed or updates are forced -> [Help 1]

Now, I understand what this means, and can simply re-run my command with -U, and things usually work fine from there on out.

However, I find this error message to be extremely unintuitive and am trying to spare my co-workers some headaches.

I am trying to figure out if there is some place that I can modify this update interval setting.

  1. Is the update interval that is mentioned in this error message a client-side or server-side setting?
  2. If client-side, how do I configure it?
  3. If server-side, does anyone know how/if Nexus/Artifactory expose these settings?

13条回答
看风景的人
2楼-- · 2019-01-01 08:29

How I got this problem,

When I changed from Eclipse Juno to Luna, and checkout my maven projects from SVN repo, I got the same issues while building the applications.

What I tried? I tried clean Local repository and then updating all the versions again using -U option. But my problem continued.

Then I went to Window --> Preferences -> Maven --> User Settings --> and clicked on Reindex button under Local Repository and wait for the reindex to happen.

That's all, the issue is resolved.

查看更多
浮光初槿花落
3楼-- · 2019-01-01 08:32

According to the settings reference:

updatePolicy: This element specifies how often updates should attempt to occur. Maven will compare the local POM’s timestamp (stored in a repository’s maven-metadata file) to the remote. The choices are: always, daily (default), interval:X (where X is an integer in minutes) or never.

Example:

<profiles>
    <profile>
      ...
      <repositories>
        <repository>
          <id>myRepo</id>
          <name>My Repository</name>
          <releases>
            <enabled>false</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
         </repository>
      </repositories>
      ...
    </profile>
  </profiles>
  ...
</settings>
查看更多
残风、尘缘若梦
4楼-- · 2019-01-01 08:32

If you are using Eclipse then go to Windows -> Preferences -> Maven and uncheck the "Do not automatically update dependencies from remote repositories" checkbox.

This works with Maven 3 as well.

查看更多
何处买醉
5楼-- · 2019-01-01 08:32

While you can resolve this with a clean install (overriding any cached dependencies) as @Sanjeev-Gulgani suggests with

mvn -U clean install

You can also simply remove the cached dependency that is causing the problem with

mvn dependency:purge-local-repository -DmanualInclude="groupId:artifactId"

See mvn docs for more info.

查看更多
呛了眼睛熬了心
6楼-- · 2019-01-01 08:33

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>
查看更多
回忆,回不去的记忆
7楼-- · 2019-01-01 08:38

you can delete the corresponding failed artifact directory in you local repository. And also you can simply use the -U in the goal. It will do the work. This works with maven 3. So no need to downgrade to maven 2.

查看更多
登录 后发表回答