使用maven,我偶尔会遇到来自第三方回购的工件,这些工件我还没有构建或包含在我的存储库中。

我将从maven客户端得到一个错误消息,说无法找到工件:

无法找到org.jfrog.maven.annomojo:maven-plugin-anno:jar:1.4.0 在http://myrepo:80/artifactory/repo中缓存在本地 存储库,解析将不会重新尝试,直到更新 MyRepo的时间间隔已过或更新被强制->[帮助1]

现在,我明白了这意味着什么,并且可以简单地用-U重新运行我的命令,从那时起,事情通常都能正常工作。

然而,我发现这个错误消息非常不直观,我试图让我的同事们不那么头疼。

我试图弄清楚是否有一些地方,我可以修改这个更新间隔设置。

此错误消息中提到的更新间隔是客户端设置还是服务器端设置? 如果是客户端,如何配置? 如果是服务器端,有人知道Nexus/Artifactory如何公开这些设置吗?


当前回答

这个错误有时会误导人。你可能需要检查两件事:

Is there an actual JAR for the dependency in the repo? Your error message contains a URL of where it is searching, so go there, and then browse to the folder that matches your dependency. Is there a jar? If not, you need to change your dependency. (for example, you could be pointing at a top level parent dependency, when you should be pointing at a sub project) If the jar exists on the remote repo, then just delete your local copy. It will be in your home directory (unless you configured differently) under .m2/repository (ls -a to show hidden if on Linux).

其他回答

这个错误有时会误导人。你可能需要检查两件事:

Is there an actual JAR for the dependency in the repo? Your error message contains a URL of where it is searching, so go there, and then browse to the folder that matches your dependency. Is there a jar? If not, you need to change your dependency. (for example, you could be pointing at a top level parent dependency, when you should be pointing at a sub project) If the jar exists on the remote repo, then just delete your local copy. It will be in your home directory (unless you configured differently) under .m2/repository (ls -a to show hidden if on Linux).

在您从本地maven存储库中删除相关依赖项之后,这就可以工作了

/user/.m2/repository/path

确保您正在寻找的工件是存在的,如果它在您的本地项目运行: cd . . CD项目名称 MVN清洁安装

然后你就可以在当地吃了。

为了更好的练习,请: MVN清洁部署,因此您可以再次使用它而不会出现此问题

我在另一件藏物上也犯了类似的错误。

<……>已缓存在本地存储库中,将不会重新尝试解析 直到中央的更新间隔已过或强制更新

以上所描述的解决方案对我都不起作用。我最终在IntelliJ IDEA解决了这个问题 文件>无效缓存/重启…>无效并重启。

我有一个相关的问题,但拉格拉姆的回答帮了我。(我还没有足够的声誉来为他的答案投票)。我正在使用与NetBeans捆绑的Maven,并且得到了相同的“…被缓存在本地存储库中,在nexus的更新间隔已过或更新被强制之前不会重新尝试解析->[帮助1]"错误。

为了解决这个问题,我添加了<updatePolicy>always</updatePolicy>到我的设置文件(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>