maven多模块项目的java最佳方法
当我需要指定子模块与父模块的依赖关系时,我对多模块maven project有问题
这是我的pom配置。xml
父POM:
<groupId>com.parent</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>childA</module>
<module>childB</module>
</modules>
childA POM
<parent>
<groupId>com.parent</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>childA</artifactId>
<dependencies>
<dependency>
<groupId>com.parent</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
ChildB POM
<parent>
<groupId>com.parent</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>childB</artifactId>
在childB中运行mvn clean install
时,我能够构建childB
我在生成带有错误消息的父和子时出错
ERROR] Failed to execute goal on project parent: Could not resolve dependencies for project com.parent:childA:jar:1.0-SNAPSHOT: Could not find artifact com.parent:parent:jar:1.0-SNAPSHOT -> [Help 1]
我需要在childA pom中增加依赖性。xml到父包,因为父包上有一些可用的类
我应该如何解决这个问题
# 1 楼答案
pom毫无意义
它与依赖项父项和构建依赖项具有相同的工件:
以及:
第一:依赖解决方案永远不会成功,因为这是一个鸡和蛋的问题
生成pom的父模块将仅在反应堆构建终止时可用,但它将仅在
childA
中的所有模块将终止其构建时终止第二:多模块maven项目和父模块被设计成
pom
,而不是jar
将其声明为
childA
的依赖项符合哪些利益只需删除它并将其作为
childA
的父级不需要将其指定为依赖项即可实现
子项目从父项目继承了许多东西,包括依赖项