C---->B---->A
C依赖于B,B依赖于A,A是老大,B是老二,C是老三。
先建立A,B,C三个模块
在B的pom.xml中的<dependencyManagement>标签里导入A的坐标,即
<dependency>
<groupId>com.example.A</groupId>
<artifactId>example-A</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
将A打成jar包,并安装到本地依赖,具体步骤:
点击A的pom.xml,run as>Maven build>在Goals中填入clean package。
B依赖于A,具体步骤:
点击B的pom.xml, run as>Maven build>在Goals中填入clean compile即可。
同理:C依赖于B。
另外,有个排除依赖,即C只想依赖于B,不想依赖于A,需要在pom.xml用到
<exclusions>
<exclusion>
<groupId>com.example.A</groupId>
<artifactId>example-A</artifactId>
</exclusion>
</exclusions>