如何在maven中添加到原始parent的相对路径

How to add relative path to the original parent in maven

我在我的 parent pom 中添加了一个从开源社区派生的子模块。 它有自己的 parent。 抛出以下内容:

[ERROR] Failed to read Maven project: 2 problems were encountered while building the effective model for com.offbytwo.jenkins:jenkins-client:0.2.1.302.1 [WARNING] 'parent.relativePath' points at com.verigreen:verigreen-root instead of org.sonatype.oss:oss-parent, please verify your project structure @ line 18, column 10 [FATAL] Non-resolvable parent POM: Failure to transfer org.sonatype.oss:oss-parent:pom:7 from http://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. Original error: Could not transfer artifact org.sonatype.oss:oss-parent:pom:7 from/to central (http://repo.maven.apache.org/maven2): connection timed out to http://repo.maven.apache.org/maven2/org/sonatype/oss/oss-parent/7/oss-parent-7.pom and 'parent.relativePath' points at wrong local POM @ line 18, column 10 for project com.offbytwo.jenkins:jenkins-client:0.2.1.302.1 at C:\Verigreen\VG_test_branches\jenkins-client\pom.xml

我的 parent pom 看起来像这样:

<artifactId>verigreen-root</artifactId>
    <version>1.6.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>verigreen</name>
    .
    .
    <modules>
        <module>jenkins-client</module>
        <module>vg-common</module>

jenkins-client pom 看起来像这样:

<name>Jenkins Client</name>
    <url>http://github.com/RisingOak/jenkins-client</url>
    <description>A Jenkins API client for Java</description>

    <groupId>com.offbytwo.jenkins</groupId>
    <artifactId>jenkins-client</artifactId>
    <version>0.2.1.302.1</version>
    <packaging>jar</packaging>

    <parent>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>7</version>
    </parent>

如何指向 parent pom?

你的parent信息有误,改成这样:

<parent>
    <groupId>com.verigreen</groupId>
    <artifactId>verigreen-root</artifactId>
    <version>1.6.1-SNAPSHOT</version>
</parent>

并在 parent pom:

上添加这个(以防它不存在)
<groupId>com.verigreen</groupId>