首先看,在maven下,对微服务进行聚合时候,看到parentId和dependencyManagement。很相似。所以这里,我想对这两个标签进行说明一下,把自己的经验告诉大家。
如图:
以下为parentId的方式:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
以下为dependencyManagement的方式:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.5.9.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
以上两种整合方式,针对不进行聚合依赖的情况下,而且只是单独的ssm项目情况,没有区别。
但是,一旦项目存在聚合,子类和父类不能都存在一样的。这是因为springboot在创建单应用项目的时候,有默认的依赖;我们在自定义wyait-parent项目时,如果直接以springboot的parent作为wyait-parent项目的父依赖管理的话,子项目会由于存在两个parent而报错,无法导入依赖。
所以,存在的标签,它是所有dependency的顶级父类,类似parenid的效果,但是,他可以存在多个。而且,更好的管理对应的jar,可以把jar单独在对应的顶级依赖父类里面统一管理
针对cloud和boot的聚合依赖下,我项目就采用了方案去解决依赖冲突问题。