首页 > 解决方案 > Maven 在 Central 中搜索本地可用的工件

问题描述

无法理解为什么 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 的情况下构建成功。

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

标签: javamaven

解决方案


您正在使用 SNAPSHOT,因此 maven 会尝试找出是否有具有相同 (SNAPSHOT) 版本的更新版本。考虑使用 maven 选项:

 -o,--offline                           Work offline


推荐阅读