不可解析的父 POM,尽管 relativePath 设置为现有的父 pom.xml
Posted
技术标签:
【中文标题】不可解析的父 POM,尽管 relativePath 设置为现有的父 pom.xml【英文标题】:Non resolvable parent POM although relativePath set to existing parent pom.xml 【发布时间】:2017-05-23 05:53:05 【问题描述】:我的项目有结构
pom.xml (parent)
tcp/pom.xml
spark/pom.xml
模块 xmls 都包含这个简介
<parent>
<groupId>org.myorg</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
我也尝试过将relativePath
留空,或者留给../
或..
,甚至根本不包括它。在所有情况下,结果都是:
[ERROR] The build could not read 2 projects -> [Help 1]
[ERROR]
[ERROR] The project org.myorg:tcpclient:1.0.0 (/git/MYorg/tcp/pom.xml) has 1 error
[ERROR] Non-resolvable parent POM for org.myorg:tcpclient:1.0.0:
Failure to find org.myorg:parent:pom:1.0 in https://repository.apache.org/content/repositories/snapshots was cached in
the local repository, resolution will not be reattempted until
the update interval of Maven snapshots repository has elapsed or updates
are forced and 'parent.relativePath' points at wrong local POM @ line 24,
column 9 -> [Help 2]
所以我可以借助这些多模块构建的帮助。
更新以下是输出的最后一部分
mvn clean install -U -X > out 2>&1
INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from /usr/local/Cellar/maven/3.3.9/libexec/conf/settings.xml
[DEBUG] Reading user settings from /Users/steve/.m2/settings.xml
[DEBUG] Reading global toolchains from /usr/local/Cellar/maven/3.3.9/libexec/conf/toolchains.xml
[DEBUG] Reading user toolchains from /Users/steve/.m2/toolchains.xml
[DEBUG] Using local repository at /Users/steve/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /Users/steve/.m2/repository
[INFO] Scanning for projects...
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://repository.apache.org/content/repositories/snapshots
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repository.apache.org/content/repositories/snapshots
Downloading: https://repository.apache.org/content/repositories/snapshots/org/openchai/parent/1.0/parent-1.0.pom
[DEBUG] Writing tracking file /Users/steve/.m2/repository/org/openchai/parent/1.0/parent-1.0.pom.lastUpdated
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://repo.maven.apache.org/maven2
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repo.maven.apache.org/maven2
Downloading: https://repo.maven.apache.org/maven2/org/openchai/parent/1.0/parent-1.0.pom
[DEBUG] Writing tracking file /Users/steve/.m2/repository/org/openchai/parent/1.0/parent-1.0.pom.lastUpdated
[DEBUG] Skipped remote request for org.openchai:parent:pom:1.0, already updated during this session.
[DEBUG] Extension realms for project org.openchai:parent:pom:1.0.0: (none)
[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-jar-plugin @ line 223, column 21
[FATAL] Non-resolvable parent POM for org.openchai:tcpclient:1.0.0: Could not find artifact org.openchai:parent:pom:1.0 in Maven snapshots repository (https://repository.apache.org/content/repositories/snapshots) and 'parent.relativePath' points at wrong local POM @ line 24, column 9
[FATAL] Non-resolvable parent POM for org.openchai:spark_p2prdd:1.0.0: Failure to find org.openchai:parent:pom:1.0 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 24, column 10
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-install-plugin is missing. @ line 90, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ line 168, column 15
@
[ERROR] The build could not read 2 projects -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-jar-plugin @ line 223, column 21
[FATAL] Non-resolvable parent POM for org.openchai:tcpclient:1.0.0: Could not find artifact org.openchai:parent:pom:1.0 in Maven snapshots repository (https://repository.apache.org/content/repositories/snapshots) and 'parent.relativePath' points at wrong local POM @ line 24, column 9
[FATAL] Non-resolvable parent POM for org.openchai:spark_p2prdd:1.0.0: Failure to find org.openchai:parent:pom:1.0 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 24, column 10
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-install-plugin is missing. @ line 90, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ line 168, column 15
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:422)
at org.apache.maven.graph.DefaultGraphBuilder.collectProjects(DefaultGraphBuilder.java:419)
at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor(DefaultGraphBuilder.java:410)
at org.apache.maven.graph.DefaultGraphBuilder.build(DefaultGraphBuilder.java:83)
at org.apache.maven.DefaultMaven.buildGraph(DefaultMaven.java:491)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:219)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR]
[ERROR] The project org.openchai:tcpclient:1.0.0 (/git/OCspark/tcp/pom.xml) has 1 error
[ERROR] Non-resolvable parent POM for org.openchai:tcpclient:1.0.0: Could not find artifact org.openchai:parent:pom:1.0 in Maven snapshots repository (https://repository.apache.org/content/repositories/snapshots) and 'parent.relativePath' points at wrong local POM @ line 24, column 9 -> [Help 2]
org.apache.maven.model.resolution.UnresolvableModelException: Could not find artifact org.openchai:parent:pom:1.0 in Maven snapshots repository (https://repository.apache.org/content/repositories/snapshots)
at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:197)
at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:246)
at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:1000)
at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:800)
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:329)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:469)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:438)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:555)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:438)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:401)
at org.apache.maven.graph.DefaultGraphBuilder.collectProjects(DefaultGraphBuilder.java:419)
at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor(DefaultGraphBuilder.java:410)
at org.apache.maven.graph.DefaultGraphBuilder.build(DefaultGraphBuilder.java:83)
at org.apache.maven.DefaultMaven.buildGraph(DefaultMaven.java:491)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:219)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact org.openchai:parent:pom:1.0 in Maven snapshots repository (https://repository.apache.org/content/repositories/snapshots)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:294)
at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:193)
... 27 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.openchai:parent:pom:1.0 in Maven snapshots repository (https://repository.apache.org/content/repositories/snapshots)
at org.eclipse.aether.
【问题讨论】:
如果使用 intelliJ,你也可以试试这个 [Preferences > Build, Execution, Deployment > Build Tools > Maven > Importing > Uncheck 'Import Maven projects automatically'] 并再次构建项目。这只会避免在 IDEA 和 Maven 中同步模块/项目。如果 intelliJ 缓存了不正确的密钥,可能会起作用。 理所当然地,至少五年来我一直没有检查。 【参考方案1】:在这么多需要跟踪的细节中,我犯了以下错误:
父版本被列为1.0
。父 pom.xml 中的实际版本是1.0.0
。
我没有概念上的误解:只关注细节。
【讨论】:
【参考方案2】:我刚刚在 poms 中看到了版本差异。 1.0.0 和 1.0。查看? 哦,你更新了一样的:)
【讨论】:
感谢您的关注 - 是的,您错过了 12 个小时;) 无论如何我都会给您一个支持。【参考方案3】:这个问题的主要答案应该是When maven says "resolution will not be reattempted until the update interval of MyRepo has elapsed", where is that interval specified? 我猜你可能在某个阶段构建项目时尝试了不正确的 relativePath,并且尝试生成工件并失败了,但现在 pom.xml 被缓存时使用了不正确的 relativePath,并且会继续抛出错误。
如果您只是不想删除存储库,还建议您通过this answerHow do you clear Apache Maven's cache? 使用清除缓存的有效方法
更多关于<relativePath>
,以及它的用途 -
父
pom.xml
文件的相对路径 在结帐内。默认值为
../pom.xml
。Maven首先在当前构建项目的reactor中查找父pom,然后在文件系统的这个位置,然后是本地仓库,最后是远程仓库。
relativePath
允许您选择不同的位置,例如当您的结构是平坦的,或者在没有中间父 pom 的情况下更深。但是,组 ID、工件 ID 和版本仍然是必需的, 并且必须与给定位置的文件匹配,否则它将恢复到 POM 的存储库。
此功能仅用于增强该项目在本地结帐时的开发。
在您的情况下,问题中描述的结构不需要明确定义 relativePath
并且可以使用其默认值跳过其声明。
【讨论】:
我已经尝试过默认设置 - 结果相同。看了你的答案后,我在 .m2 下删除了,还尝试了 mvn -U 。没有骰子。一件真正困扰我的事情;错误 (a) 的行号与 pom.xml 的当前版本中的行号不匹配,并且 (b) 不会改变,无论我对 pom.xml 做什么。我不知道 mvn 如何/在哪里获取旧版本/不同版本 @javadba 行号不匹配是我写的原因 ".. pom.xml is cached" 你的日志(使用-X
)在执行mvn clean install
时应该是您可能要检查的两个重要文件的位置(如果它们可能已更新)...1。 settings.xml 来自全局或用户设置,以确认您没有任何 updatePolicy 更改 2. .m2/ 中的 maven-metadata.xml 以验证它是上次更新 pom 的时间
用mvn clean install -U -X
的输出更新了OP。由于暴风雨和互联网中断,我的回复延迟。以上是关于不可解析的父 POM,尽管 relativePath 设置为现有的父 pom.xml的主要内容,如果未能解决你的问题,请参考以下文章