Maven在Central仓库中搜索一个在本地可用的构件。

huangapple 未分类评论65阅读模式
标题翻译

Maven searches an artifact in Central that is available in local

问题

无法理解为什么 Maven 在中央 Maven 仓库中查找一个已经在本地仓库中可用的构件。

以下是错误输出:

[FATAL] Non-resolvable parent POM for a.b.c:app:1.23-SNAPSHOT: Failure to find a.b.c:parent:pom:1.16.52 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 6, column 13

a.b.c:parent:pom:1.16.52 在我的本地 Maven 仓库中可用。

以下是我的 settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<localRepository/>
	<interactiveMode/>
	<usePluginRegistry/>
	<offline>false</offline>
	<pluginGroups/>
	<mirrors/>
	<proxies/>
</settings>

运行 mvn -o ... 会导致:

Non-resolvable parent POM for a.b.c:app:1.23-SNAPSHOT: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact a.b.c:parent:pom:1.16.52 has not been downloaded from it before. and 'parent.relativePath' points at wrong local POM @ line 6, column 13 -> [Help 2]

是怎么引发这个问题的?我想从公司的 Nexus 中使用一些依赖项来构建应用程序。当 Nexus 的信息在 settings.xml 中时,构建是成功的。在那次构建之后,我从 settings.xml 中移除了 Nexus 的配置,希望能够在不依赖 Nexus 的情况下构建应用程序。

好的,答案 https://stackoverflow.com/a/47338002/971355 对我有帮助。问题在于所有的 _remote.repositories 文件。在删除它们之后,构建在没有 Nexus 的情况下成功了。

我认为我的问题可以标记为重复。

英文翻译

Cannot understand why Maven looks for an artifact in the Central Maven repository although it's available in the local one.

Below is the error output:

[FATAL] Non-resolvable parent POM for a.b.c:app:1.23-SNAPSHOT: Failure to find a.b.c:parent:pom:1.16.52 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and &#39;parent.relativePath&#39; points at wrong local POM @ line 6, column 13

a.b.c:parent:pom:1.16.52 is available in my local Maven repo.

Below is my settings.xml:

&lt;settings xmlns=&quot;http://maven.apache.org/SETTINGS/1.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd&quot;&gt;
	&lt;localRepository/&gt;
	&lt;interactiveMode/&gt;
	&lt;usePluginRegistry/&gt;
	&lt;offline&gt;false&lt;/offline&gt;
	&lt;pluginGroups/&gt;
	&lt;mirrors/&gt;
	&lt;proxies/&gt;
&lt;/settings&gt;

Running mvn -o ... leads to:

Non-resolvable parent POM for a.b.c:app:1.23-SNAPSHOT: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact a.b.c:parent:pom:1.16.52 has not been downloaded from it before. and &#39;parent.relativePath&#39; points at wrong local POM @ line 6, column 13 -&gt; [Help 2]

How did it come to this? I wanted to build the app by using some dependencies from a corporate Nexus. The build worked when information about Nexus was in settings.xml. After that build I removed Nexus configuration from settings.xml and wanted to build the app without depending on Nexus.

Ok. The answer https://stackoverflow.com/a/47338002/971355 helped.
The problem was in all the _remote.repositories files. After their deletion the build was successful without Nexus.

I think my question can be marked as duplicate.

答案1

得分: 0

你正在使用 SNAPSHOT 版本,因此 Maven 会尝试查找是否存在相同(SNAPSHOT)版本的更新构建。考虑使用以下 Maven 选项:

-o,--offline                           离线工作
英文翻译

You are using SNAPSHOT, so maven attempts to find out if there is newer build with the same
(SNAPSHOT) version.Consider using maven option:

 -o,--offline                           Work offline

huangapple
  • 本文由 发表于 2020年3月16日 17:13:01
  • 转载请务必保留本文链接:https://java.coder-hub.com/60703139.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定