无法解析的父POM for找不到工件,'parent.relativePath'指向错误的本地POM

时间:2012-10-17 04:05:48

标签: build maven-3 packaging pom.xml

我是maven的新手。

我有一个项目,我尝试用maven3构建。

当我运行命令mvn -X clean install时,我收到了错误。

[root@localhost]# mvn -X clean install
Apache Maven 3.0.4 (r1232337; 2012-01-17 14:14:56+0530)
Maven home: /usr/local/maven
Java version: 1.6.0_24, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-279.9.1.el6.x86_64", arch: "amd64", family: "unix"
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from /usr/local/maven/conf/settings.xml
[DEBUG] Reading user settings from /root/.m2/settings.xml
[DEBUG] Using local repository at /root/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for /root/.m2/repository
[INFO] Scanning for projects...
[DEBUG] Could not find metadata com.test.ctrl:ctrl-build:0.0.17-SNAPSHOT/maven-metadata.xml in local (/root/.m2/repository)
[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for org.openstack:openstack-rhel-rpms:2012.1-SNAPSHOT: Could not find artifact com.test.ctrl:ctrl-build:pom:0.0.17-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ org.openstack:openstack-rhel-rpms:2012.1-SNAPSHOT, /root/test/devenv/openstack-rhel/pom.xml, line 8, column 13

        at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:363)
        at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:636)
        at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:585)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:234)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[ERROR]
[ERROR]   The project org.openstack:my-tar:2012.1-SNAPSHOT (/root/test/devenv/mytar/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for org.openstack:openstack-rhel-rpms:2012.1-SNAPSHOT: Could not find artifact com.test.ctrl:ctrl-build:pom:0.0.17-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ org.openstack:openstack-rhel-rpms:2012.1-SNAPSHOT, /root/test/devenv/openstack-rhel/pom.xml, line 8, column 13 -> [Help 2]
org.apache.maven.model.resolution.UnresolvableModelException: Could not find artifact com.test.ctrl:ctrl-build:pom:0.0.17-SNAPSHOT
        at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:159)
        at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:813)
        at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:664)
        at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:310)
        at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:232)
        at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:410)
        at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:379)
        at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:343)
        at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:636)
        at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:585)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:234)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not find artifact com.test.ctrl:ctrl-build:pom:0.0.17-SNAPSHOT
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:538)
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:193)
        at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:286)
        at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:155)
        ... 22 more
Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact com.test.ctrl:ctrl-build:pom:0.0.17-SNAPSHOT
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:528)
        ... 26 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

我检查了pom.xml,但无法理解问题所在。 我的pom.xml中的某些行如下所示。

  1 <?xml version="1.0"?>
  2 <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
  3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  4   <modelVersion>4.0.0</modelVersion>
  5
  6 <parent>
  7     <groupId>org.openstack</groupId>
  8     <artifactId>openstack-rhel-rpms</artifactId>
  9     <version>2012.1-SNAPSHOT</version>
 10     <relativePath>../openstack-rhel</relativePath>
 11 </parent>
 12
 13     <groupId>org.openstack</groupId>
 14     <artifactId>my-tar</artifactId>
 15     <version>2012.1-SNAPSHOT</version>
 16   <packaging>pom</packaging>
 17   <name>my tar</name>
 18

我还在stackoverflow中检查了一些问题的解决方案,如Non-resolvable parent POM: Could not find artifact,但无法帮助解决问题。

如果您需要与此问题相关的更多信息,请与我们联系。

9 个答案:

答案 0 :(得分:11)

我遇到了同样的问题。设置模块项目中父项的相对路径解决了该问题。

使用<relativePath>../Parent Project Name/pom.xml</relativePath>

答案 1 :(得分:7)

您需要拥有文件/root/test/devenv/openstack-rhel/pom.xml

此文件需要具有以下元素:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.openstack</groupId>
    <artifactId>openstack-rhel-rpms</artifactId>
    <version>2012.1-SNAPSHOT</version>
    <packaging>pom</packaging>
</project>

答案 2 :(得分:1)

我们遇到了同样的问题。

父pom文件在我们的本地存储库中可用,但maven仍未成功尝试从中央存储库或 relativePath 下载(相对路径中没有文件)。< / p>

事实证明,本地存储库中有一个名为“_ remote.repositories”的文件,导致此行为。从完整的本地存储库中删除具有此名称的所有文件后,我们可以构建我们的模块。

答案 3 :(得分:1)

我使用Maven Release Plugin遇到了这样的问题。解决使用相对路径(即子模块中的父pom ../parent/pom.xml)在这种情况下似乎不起作用,它一直在Nexus存储库中查找已发布的父pom。将父pom移动到模块的父文件夹解决了这个问题。

答案 4 :(得分:1)

以任何方式提及/root/.m2/settings.xml。

但是在我的情况下,我错过了在Maven首选项中配置的settings.xml。 enter image description here,以便Maven从settings.xml中配置的remote_repository中搜索relative_path pom.xml

答案 5 :(得分:0)

确保您具有settings.xml。当我误删除它时,我遇到了同样的问题。

答案 6 :(得分:0)

在项目的pom.xml文件中,

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>X.X.X.RELEASE</version>
<relativePath> ../PROJECTNAME/pom.xml</relativePath>
</parent>

将相对路径指向同一MAVEN项目POM文件为我解决了此问题。

答案 7 :(得分:0)

就我而言,原因是一个简单的错字。

<parent>
    <groupId>org.sringframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.5.RELEASE</version>
</parent>

groupId org.s(p)ringframework中缺少字符导致此错误。

答案 8 :(得分:0)

将相对路径URL值提供给pom.xml文件
../ parentfoldername / pom.xml