当maven说“在MyRepo的更新间隔过去之前不会重新尝试解析”时,该间隔在哪里指定?
使用 Maven,我偶尔会遇到来自某些 3rd 方存储库的工件,但我尚未构建或包含在我的存储库中。
我将从 Maven 客户端收到一条错误消息,指出找不到工件:
找不到 org.jfrog.maven.annomojo:maven-plugin-anno:jar:1.4.0
http://myrepo:80/artifactory/repo
中被缓存在本地 存储库,在更新之前不会重新尝试解析 MyRepo 的间隔已过或强制更新 -> [帮助1]
现在,我明白这意味着什么,并且可以简单地使用 -U
重新运行我的命令,从那时起事情通常会正常工作。
然而,我发现这个错误消息非常不直观,我试图让我的同事免于一些麻烦。
我试图弄清楚是否有地方可以修改此更新间隔
设置。
- 此错误消息中提到的
更新间隔
是客户端设置还是服务器端设置? - 如果是客户端,如何配置?
- 如果是服务器端,有谁知道 Nexus/Artifactory 如何/是否公开这些设置?
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
inhttp://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.
- Is the
update interval
that is mentioned in this error message a client-side or server-side setting? - If client-side, how do I configure it?
- If server-side, does anyone know how/if Nexus/Artifactory expose these settings?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(26)
我曾经通过删除本地存储库中相应的无法下载工件目录来解决此问题。下次我运行 Maven 命令时,会再次触发工件下载。因此我会说这是客户端设置。
Nexus端(服务器repo端),这个问题是通过配置计划任务来解决的。
客户端,这是使用
-U
完成的,正如您已经指出的那样。I used to solve this issue by deleting the corresponding failed to download artifact directory in my local repo. Next time I run the maven command the artifact download is triggered again. Therefore I'd say it's a client side setting.
Nexus side (server repo side), this issue is solved configuring a scheduled task.
Client side, this is done using
-U
, as you already pointed out.基本上发生的事情是,根据 maven 的默认 updatePolicy,maven 每天都会从 repo 中获取 jar。因此,如果在第一次尝试期间您的互联网无法正常工作,那么在 24 小时过去之前,它不会再次尝试获取此 jar。
解决方案:
使用
(其中 -U 将强制更新存储库)
使用
或在 settings.xml 中
What basically happens is, according to the default updatePolicy of maven, maven will fetch the jars from the repo on a daily basis. So if during the first attempt your Internet was not working, then it would not try to fetch this jar again until 24hours has passed.
Resolution:
Either use
(where -U will force update the repo)
or use
in your settings.xml
您可以删除本地存储库中相应的失败工件目录。您也可以简单地在目标中使用
-U
。它会完成工作。这适用于 maven 3。因此无需降级到 maven 2。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.我有一个相关的问题,但拉古拉姆的回答有帮助。 (我还没有足够的声誉来投票支持他的答案)。我正在使用与 NetBeans 捆绑在一起的 Maven,并得到相同的“...已缓存在本地存储库中,在 nexus 的更新间隔已过或强制更新之前,不会重新尝试解析 -> [帮助 1]”错误。
为了解决这个问题,我将
always
添加到我的设置文件 (C:\Program Files\NetBeans 7.0\java\maven\conf\settings.xml)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)虽然您可以通过干净安装(覆盖任何缓存的依赖项)来解决此问题,正如 @Sanjeev-Gulgani 建议的
mvn -U clean install
您也可以简单地删除导致问题的缓存依赖项,
请参阅 < a href="http://maven.apache.org/plugins/maven-dependency-plugin/purge-local-repository-mojo.html" rel="noreferrer">mvn 文档 了解更多信息。
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
See mvn docs for more info.
根据设置参考:
示例:
According to the settings reference:
Example:
从本地 Maven 存储库中删除相关依赖项后,此操作将起作用
This works after you delete the related dependency from your local maven repository
此错误有时可能会产生误导。您可能需要检查两件事:
存储库中是否有依赖项的实际 JAR?您的错误消息包含正在搜索的 URL,因此请转到那里,然后浏览到与您的依赖项匹配的文件夹。有罐子吗?如果没有,您需要改变您的依赖关系。 (例如,当您应该指向子项目时,您可能会指向顶级父依赖项)
如果远程存储库上存在该 jar,则只需删除本地副本。它将位于您的主目录(除非您配置不同)下的 .m2/repository(如果在 Linux 上,则 ls -a 显示隐藏)。
This error can sometimes be misleading. 2 things you might want to check:
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).
如果您使用的是 Eclipse,请转到 Windows ->首选项-> Maven 并取消选中“不自动更新远程存储库的依赖项”复选框。
这也适用于 Maven 3。
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.
您需要从存储库中删除所有“_maven.repositories”文件。
You need to delete all "_maven.repositories" files from your repository.
我在使用不同的工件时遇到了类似的错误。
上述解决方案都不适合我。我终于在 IntelliJ IDEA 中解决了这个问题
文件>使缓存无效/重新启动...>无效并重新启动。
I had a similar error with a different artifact.
None of the above described solutions worked for me. I finally resolved this in IntelliJ IDEA by
File > Invalidate Caches / Restart ... > Invalidate and Restart.
对于Intellij用户,以下对我有用:
右键单击您的包
并
For Intellij users the following worked for me:
Right click on your package
and
如果您使用 Nexus 作为代理存储库,它具有“未找到缓存 TTL”设置,默认值为 1440 分钟(或 24 小时)。降低此值可能会有所帮助(存储库 > 配置 > 过期设置)。
有关详细信息,请参阅文档。
If you use Nexus as a proxy repo, it has "Not Found Cache TTL" setting with default value 1440 minutes (or 24 hours). Lowering this value may help (Repositories > Configuration > Expiration Settings).
See documentation for more info.
最后回答标题问题:它是(项目、配置文件或设置)
...标签中的(客户端设置)。
(目前,maven:3.6.0,但我认为“向后”兼容)可能的值是:
当前(maven 3.6.0)对该标签的评估实现如下:
..和:
...其中
lastModified
是每个底层工件的(本地文件)“修改时间戳”。特别是对于
interval:x
设置::
并不那么严格 - 任何“非空”字符都可以做到这一点(=
,,...)。
x < 0
应该屈服于“从不”。interval:0
我会假设“每分钟”(0-59 秒或以上...)间隔。24 * 60
分钟(~“每日”)。..参见: DefaultUpdatePolicyAnalyzer,DefaultMetadataResolver#resolveMetadata() 和 RepositoryPolicy
To finally answer the title question: It is (a client side setting) in (project, profile or settings)
... tag.
The (currently, maven: 3.6.0, but I suppose "far backwards" compatible) possible values are :
The current (maven 3.6.0) evaluation of this tag is implemented as follows:
..with:
...where
lastModified
is the (local file) "modified timestamp" of an/each underlying artifact.In particular for the
interval:x
setting::
is not that strict - any "non-empty" character could do it (=
,, ...).
x < 0
should yield to "never".interval:0
I would assume a "minutely" (0-59 secs. or above...) interval.24 * 60
minutes (~"daily")...see: DefaultUpdatePolicyAnalyzer, DefaultMetadataResolver#resolveMetadata() and RepositoryPolicy
Maven 有 updatePolicy 设置,用于指定检查存储库中的更新或保持存储库与远程同步的频率。
下面的代码示例可以添加到 Maven 用户设置文件中来配置 updatePolicy。
Maven has updatePolicy settings for specifying the frequency to check the updates in the repository or to keep the repository in sync with remote.
Below code sample can be added to maven user settings file to configure updatePolicy.
我是如何遇到这个问题的,
当我从 Eclipse Juno 更改为 Luna 并从 SVN 存储库检查我的 Maven 项目时,我在构建应用程序时遇到了同样的问题。
我尝试了什么?
我尝试清理本地存储库,然后使用 -U 选项再次更新所有版本。但我的问题仍然存在。
然后我去了窗口-->首选项->梅文 -->用户设置-->并单击“本地存储库”下的“重新索引”按钮,然后等待重新索引发生。
就这样,问题就解决了。
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.
就我而言,解决方案很愚蠢:我只是有不正确的依赖版本。
In my case the solution was stupid: I just had incorrect dependency versions.
有点相关..我正在
此错误是由于意外使用 Maven 造成的3 而不是
Maven 2
。只是觉得这可能会节省一些人的时间,因为我最初的谷歌搜索将我带到了这个页面。Somewhat relevent.. I was getting
This error was caused by accidentally using
Maven 3
instead ofMaven 2
. Just figured it might save someone some time, because my initial google search led me to this page.我有同样的错误(不会重新尝试解决方案...)但我有不同的要求,因为我的本地存储库中有文件,目前无法远程使用(旧的过时的库和内部库),并且我的公司关系系统已关闭,但它们确实存在于我的 .m2 存储库中。
Maven 仍然拒绝构建,产生与上面相同的错误。
对于有问题的库,我只是删除了相应的文件:
知道这些文件仅在本地可用。
注意:长期解决方案,我可能应该启动并运行我们之前的 Nexus 系统,对于那些遗留的 jar,将它们签入项目的 lib 文件夹(或类似的文件夹)下
I had the same error, (resolution will not be reattempted...) but I had different requirements, as I have files in my local repository, that are currently not available remotely (old outdated libraries and internal libraries), and my company nexus system is down, but they do exist in my .m2 repos.
Maven still refused to build, producing the same error above.
For the offending libraries, I just removed the corresponding file:
knowing that these files are only available locally.
Note: Long term resolution, I should probably get our previous nexus system up and running, and for those jars that are legacy, check them into the project under a lib folder (or something like that)
我已经解决了!
我之前遇到过这个问题,在查看了一些评论后发现它有效。
我们只需更正 {m2_home}/.m2 下的 settings.xml 文件
并执行 maven clean install 命令。
I have resolved it!
I have encountered this issue earlier and after reviewing some comments it worked.
we only have to correct settings.xml file under {m2_home}/.m2
and execute maven clean install command.
我遇到了这个问题, this 中提出的全面描述帮助我解决了这个问题。
第二个声明的问题是我的问题。我使用了一个第三方存储库,我刚刚将其添加到我的项目中的 pom 文件的
repository
部分。我将相同的存储库信息添加到pluginrepository
中来解决此问题。I had this problem and the comprehensive descriptions proposed in this helped me to fix it.
The second declared problem was my issue. I used a third-party repository which I had just added it do the
repository
part of the pom file in my project. I add the same repository information intopluginrepository
to resolve this problem.我在我的私人存储库上上传的第三方库遇到了同样的问题。有时所描述的修复对我有用,但有时却不起作用。
我认为问题的根本原因是工件缺少 pom.xml 文件。 (第三方工件的 pom.xml 不是项目中的 pom.xml)。我假设 Maven 期望每个工件都有一个 pom.xml,因此它可以解决所有工件的依赖关系。有时它可以在没有 pom.xml 的情况下工作,但有时却不能(我还没有确定,当它不能时)。
我使用 Nexus3 作为私人存储库。上传工件时,您可以选中一个选项来为工件生成 pom.xml 文件。
I ran into the same problems with uploaded third party libraries on my private repository. Sometimes the described fixes worked for me, but sometimes they did not.
I think the root cause of the problem is a missing pom.xml file for the artifact. (The pom.xml for the third party artifact not your pom.xml in your project). I assume Maven expects for every artifact a pom.xml, so it can resolve the dependencies for all artifacts. Sometimes it works without a pom.xml, but sometimes it does not (I have not identified, when it does not).
I use Nexus3 as a private repository. When you upload an artifact, you can check an option to generate a pom.xml file for the artifact.
更改我的 settings.xml 中的 localRepository 路径解决了该问题
Changing the localRepository path in my settings.xml solved the issue
我已经尝试了以下解决方案,但没有一个对我有用(使用 eclipse 嵌入的 maven):
我见过很多这样的解决方案解决方案有很多赞成票,但它们已经很旧了,所以我猜它们曾经工作过一次,但现在不再有效(至少对于嵌入 eclipse 的 maven 来说)。
什么对我有用:
在 Eclipse 中转到 Window >首选项> Maven 并将“全局更新策略”字段设置为“始终”。
I have tried the following solutions but none worked for me (with eclipse-embedded maven):
I've seen many of these solution with lot of upvotes, but they are pretty old, so I guess they worked once, but nowdays are no longer valid (at least for eclipse-embedded maven).
What worked for me:
in Eclipse go to Window > Preferences > Maven and set the "Global Update Policy" field to "Always".
转到您的 Pom 文件,右键单击并向下滚动,然后单击 maven 打开 settings.xml 文件(如您从图像中看到的)并添加以下代码(到您的 settings.xml 文件),然后保存并关闭并等待让maven重新加载。
然后刷新/重新加载您的 pom 文件/项目。
N:B 您可能必须转到您的主 Spring Boot 类和 @SprinBootApplication 之上的 Hoover,然后单击建议添加 Maven 依赖项......
这将重新安装您可能丢失的本地 Maven 依赖项。
Go to your Pom file and right-click and scroll down then click on maven to open the settings.xml file (as you see from the image) and add the following code (to your settings.xml file) then save and close and wait for maven to reload.
Then refresh/reload your pom file/project.
N:B You may have to go to your main spring boot class and Hoover on top of @SprinBootApplication then click on the suggestion to add Maven dependency ......
This will reinstall your local maven dependencies which you are likely to have lost.
确保您正在寻找的工件存在(如果它在您的本地项目运行中):
光盘 ..
光盘项目名称
mvn clean install
然后你就会在本地拥有它。
为了更好的练习,请执行以下操作:
mvn clean deploy 这样你就可以再次使用它而不会出现这个问题
Make sure that the artifact you are looking for is exist , if its on your local project run :
cd ..
cd project name
mvn clean install
Then you will have it locally.
for better practice do :
mvn clean deploy so you can use it again without this problem