Maven:不可解析的父母POM

Wil*_*ill 83 build-automation module parent-child maven

我将我的maven项目设置为1个shell项目和4个子模块.当我尝试构建shell时.我明白了:

[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR] The project module1:1.0_A0 (C:\module1\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM: Failure to find shell:pom:1.0_A0 in http://nyhub1.ny.ssmb.com:8081/nexus/content/repositories/JBoss/ was cached in the local repository, resolution will not be reattempted until the update interval of jboss has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 5, column 11 -> [Help 2]
Run Code Online (Sandbox Code Playgroud)

如果我尝试构建一个单独的模块,我得到相同的错误只替换module1,无论它是什么模块.

让他们都在他们的poms中引用父母.

<parent>
    <artifactId>shell</artifactId>
    <groupId>converter</groupId>
    <version>1.0_A0</version>
</parent>
Run Code Online (Sandbox Code Playgroud)

这是shell pom的相关部分:

<groupId>converter</groupId>
<artifactId>shell</artifactId>
<version>1.0_A0</version>
<packaging>pom</packaging>
<name>shell</name>


<modules>
    <module>module1</module>
    <module>module2</module>
    <module>module3</module>
    <module>module4</module>
</modules>
Run Code Online (Sandbox Code Playgroud)

Wil*_*ill 76

仅供参考.

Maven的乐趣.

将模块的相对路径放到../pom.xml解决了它.

parent元素有一个relativePath,你需要指向父目录的元素.它默认为..

  • 是.使用Maven需要你知道你做了什么,试验和错误不会让你走得太远.另一方面,有几个很好的参考资料.这是[一](http://www.sonatype.com/books/mvnref-book/reference/). (14认同)
  • 有人能让这一点更清楚吗? (9认同)
  • 所以你在`<parent> </ parent>`下添加了这个`<relativePath> .. </ relativePath>`? (4认同)
  • 如果您指向私有存储库,则放置 &lt;relativePath&gt; 不一定能解决问题。请查看 Tomáš Záluský 的回复以获取详细解释。 (2认同)

use*_*134 30

也可以通过将正确的settings.xml文件放入~/.m2/目录来修复它.

  • 正是这解决了我的问题,谢谢!但不是将它放入某个目录,而是在Preferences - Maven - User Settings中将Eclipse指向它. (2认同)

Tom*_*ský 15

另一个原因也可能是父工件来自无法访问的pom.xml存储库,通常是私有存储库.解决方案是在以下位置提供该存储库pom.xml:

<repositories>
    <repository>
        <id>internal-repo</id>
        <name>internal repository</name>
        <url>https://my/private/repo</url>
        <layout>default</layout>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
Run Code Online (Sandbox Code Playgroud)

在我的情况下,由于Eclipse,问题变得更加复杂:存储库仅在特殊的配置文件(<profiles><profile><id>activate-private-repo</id><repositories>...)中处于活动状态,而Eclipse中的Maven GUI不允许通过Ctrl+Alt+P快捷方式设置此配置文件.

解决方案是临时在配置文件外部(无条件地)声明存储库,启动Alt+F5Maven Update Project,激活配置文件并将存储库声明放回配置文件中.这是Eclipse错误,而不是Maven错误.


sta*_*lol 5

只需添加<relativePath />这样 pom 中的父级应该如下所示:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.4.RELEASE</version>
        <relativePath />
    </parent>
Run Code Online (Sandbox Code Playgroud)

  • 这仅适用于父级不在同一目录结构中(即在远程存储库中)的情况。 (3认同)

Wu *_*hao 5

不可解析的父 POM: 这意味着您无法解析父存储库。

在调试模式下运行:

[DEBUG] Reading global settings from **/usr/local/Cellar/maven/3.5.4/libexec/conf/settings.xml**
[DEBUG] **Reading user settings from /Users/username/.m2/settings.xml**
[DEBUG] Reading global toolchains from /usr/local/Cellar/maven/3.5.4/libexec/conf/toolchains.xml
[DEBUG] Reading user toolchains from /Users/username/.m2/toolchains.xml
[DEBUG] Using local repository at /Users/username/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /Users/username/.m2/repository
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
Run Code Online (Sandbox Code Playgroud)

因为父仓库不是 Maven 中心的一部分。解决方案是在 ~m2/ 中指定一个 setting.xml 来帮助生成父 POM。/用户/用户名/.m2/settings.xml

在该 XML 中,您可能需要指定存储库信息。

  • 什么样的细节?你能描述一下吗? (3认同)