为了避免重复引包,一般共用包放入父包中。
1.pom嵌套
parent
child1
child2
grandson1
grandson2
<parent>
<groupId>com.enjoy</groupId>
<artifactId>Parent-Moduel</artifactId>
<version>3.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
子包通过如上方式,引用父包,如果依赖关系如parent和child只有一层的关系,可以省略relativePath。grandson依赖child,不需要直接依赖parent.
2.<dependencies>和<dependencyManagement>
父包中直接<dependencies>引入的依赖包子包可以引用。
外围包一层<dependencyManagement>后,父依赖,子包是无法引用的。