Java 如何将maven父项目和子项目设置为单独的项目?
有一个项目(type=pom),应该用作另一个项目的父项目 家长Java 如何将maven父项目和子项目设置为单独的项目?,java,maven,parent-child,pom.xml,parent-pom,Java,Maven,Parent Child,Pom.xml,Parent Pom,有一个项目(type=pom),应该用作另一个项目的父项目 家长 <project> <modelVersion>4.0.0</modelVersion> <groupId>my-firm</groupId> <artifactId>custom-parent</artifactId> <version>1.0.0</version> <packaging>
<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>
错误消息中的所有三点似乎都与我的意图无关
distributionManagement
中描述的回购协议,而是对Maven.central的投诉parent.relativePath
故意不存在,以使子项目与父项目位置无关,并使其仅依赖于已部署的工件(父pom)pom
s以将子项目和父项目作为单独的项目,并让子项目仅依赖于父项目。请注意
仅用于上载。如果您运行mvndeploy
,Maven就会在这里放置工件
因此,如果您希望Maven为父POM查看您的工件,您需要添加适当的
元素,或者——这是首选方式——在设置.xml
中配置您的工件
然而,如果您先在某台机器上构建父级,然后在同一台机器上构建子级,则会从本地存储库读取父级POM。它不会以任何方式从那里移除。我不知道你的情况出了什么问题,但我想你要么两个版本都有一个不同的本地存储库,要么中间的内容被删除了
<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>
[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