Non-resolvable parent POM using Maven 3.0.3 and re

2019-03-12 06:04发布

After migrating to Mavent 3.0.3 Parent poms in several Projects cannot be resolved anymore.

The Projects are structured in a default manner, so I set parent.relativePath to "../pom.xml"

superpom (located in repository)
|-rootpom (located locally: no error)
|-|-parentpom (located locally: error resolving parent)
|-|-|-module1 (located locally: error resolving parent)
|-|-|-module2 (located locally: error resolving parent)
|-|-|-module3 (located locally: error resolving parent)
|-|-|-module4 (located locally: error resolving parent)

The Error...

Non-resolvable parent POM for myGroup:myArtifactId:1.0: Failure to find myGroup:myParentArtifactId:1.0 in http://myRepo.net/archiva/repository/maven2 was cached in the local repository, resollution will not be reattempted until the update interval of maven2 has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ myGroup:myParentArtifactId:1.0, C:\myProjectDir\parent\pom.xml, line x, column y -> [Help 2]

... seems to indicate that the pom was searched for in the repository, so I wonder why the pom was not found locally before looked elsewere.

I have read that maven3 might get confused when several repositories are defined in the settings.xml, but that was always when searching for a pom inside repositories and not locally.

update

Up until now we did execute the maven build on the parent-project level (parentpom) - a fact wich I did not know was important, since maven2 completed successfully until now.

When using maven3 this seems to be of importance. When executing maven3 on the root-project level (rootpom) the build finishes successfully. So my immediate problem is solved.

Since I don't neccessarily want to answer my own question maybe someone can explain why maven3 behaves this way now or why the old approach was wrong.

8条回答
何必那么认真
2楼-- · 2019-03-12 06:33

Here is answer to your question.

By default maven looks in ../pom.xml for relativePath. Use empty <relativePath/> tag instead.

查看更多
爷的心禁止访问
3楼-- · 2019-03-12 06:34
<parent>
        <groupId>com.test.vaquar.khan</groupId>
        <artifactId>vk-parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../projectname/pom.xml</relativePath>
    </parent>

Add following line in parent

<relativePath>../projectname/pom.xml</relativePath>

You need relative path if you are building from local parent pom not available in nexsus, add pom in nexus then no need this path

查看更多
太酷不给撩
4楼-- · 2019-03-12 06:37

I had the same problem. My project layout looked like

\---super
    \---thirdparty
        +---mod1-root
        |   +---mod1-linux32
        |   \---mod1-win32
        \---mod2-root
            +---mod2-linux32
            \---mod2-win32

In my case, I had a mistake in my pom.xmls at the modX-root-level. I had copied the mod1-root tree and named it mod2-root. I incorrectly thought I had updated all the pom.xmls appropriately; but in fact, mod2-root/pom.xml had the same group and artifact ids as mod1-root/pom.xml. After correcting mod2-root's pom.xml to have mod2-root specific maven coordinates my issue was resolved.

查看更多
祖国的老花朵
5楼-- · 2019-03-12 06:45

You need to check your relative path, based on depth of your modules from parent if module is just below parent then in module put relative path as: ../pom.xml

if its 2 level down then ../../pom.xml

查看更多
The star\"
6楼-- · 2019-03-12 06:49

Make sure you Double-Check that the version you refer to in the child-pom is the same as that in the parent-pom. For me, I'd bumped version in the parent and had it as 3.1.0.0-RELEASE, but in the child-pom, I was still referring to the previous version via relativePath, and had it defined as 2.0.0.0-SNAPSHOT. It did not make any difference if I included just the parent directory, or had the "pom.xml" appended to the directory:

    <parent>        
    <artifactId>eric-project-parent</artifactId>
    <groupId>com.eric.common</groupId>
     <!-- Should be 3.1.0.0-RELEASE -->
    <version>2.0.0.0-SNAPSHOT</version>     
    <relativePath>
                ../../EricParentAsset/projects/eric-project-parent</relativePath>           
</parent>
查看更多
再贱就再见
7楼-- · 2019-03-12 06:50

'parent.relativePath' points at wrong local POM @ myGroup:myParentArtifactId:1.0, C:\myProjectDir\parent\pom.xml

This indicates that maven did search locally for the parent pom, but found that it was not the correct pom.

  • Does pom.xml of parentpom correctly define the parent pom as the pom.xml of rootpom?
  • Does rootpom folder contain pom.xml as well as the paretpom folder?
查看更多
登录 后发表回答