【发布时间】:2020-10-23 02:21:24
【问题描述】:
有一个项目(type=pom),它应该被用作另一个项目的父级。
父母
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>my-firm</groupId>
<artifactId>custom-parent</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<distributionManagement>
<repository>
<id>lib-repo-local</id>
<name>my-releases</name>
<url>http://artifactory.local:8081/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>lib-repo-snapshots</id>
<name>my-snapshots</name>
<url>http://artifactory.local:8081/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
</project>
孩子
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>my-firm</groupId>
<artifactId>custom-parent</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>child-sample</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<distributionManagement>
<repository>
<id>lib-repo-local</id>
<name>my-releases</name>
<url>http://artifactory.local:8081/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>lib-repo-snapshots</id>
<name>my-snapshots</name>
<url>http://artifactory.local:8081/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
</project>
父项目部署到远程存储库 - 工件my-firm:custom-parent:1.0.0 可用。
当我在子项目上运行mvn clean 时出现错误
[FATAL] Non-resolvable parent POM for my-firm:child-sample:0.0.1:
Failure to find my-firm:custom-parent:1.0.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 7, column 11
错误信息中的所有三点似乎都与我的意图无关。
- Maven 不会尝试查看
distributionManagement中描述的存储库,而是对 maven.central 的投诉 - 本地存储库中没有缓存任何内容 - 在构建之前从那里删除的所有工件。
- 故意缺少
parent.relativePath,以使子项目与父项目位置无关,并让它仅依赖于已部署的工件(父 pom)。
请展示如何编辑poms 以将子项和父项作为单独的项目,并让子项仅依赖于父项。
【问题讨论】:
标签: java maven parent-child pom.xml parent-pom