判断父子模块的条件
在父项目的pom.xml中要有
<modules>
<module>子项目构件名</module>
</modules>
在子项目的pom.xml中要有
<parent>
<artifactId>父项目构件名</artifactId>
<groupId>父项目groupId</groupId>
<version>父项目version</version>
</parent>
< dependencyManagement >与< dependencies>的区别:
dependencies:
所有声明在父项目中 dependencies里的依赖都会被子项目自动引入,并默认被所有的子项目继承。即使在子项目中不写该依赖项,那么子项目仍然会从父项目中继承该依赖项(全部继承)、
dependencyManagement:
只是声明依赖,并不实现引入,因此子项目需要显示的声明需要用的依赖。如果不在子项目中声明依赖,是不会从父项目中继承下来的;只有在子项目中写了该依赖项,并且没有指定具体版本,才会从父项目中继承该项,并且
version 和 scope 都读取自父 pom; 另外如果子项目中指定了版本号,那么会使用子项目中指定的jar版本。
注:此段文本来源:http://blog.sina.com.cn/s/blog_58a61a490102xqzi.html
物料清单(Bill Of Materials)
最常见的物料清单 就是spring bom
作用:
1) 防止混合不同版本的Spring JAR
项目可能因为第三方库的使用 或者其他项目的依赖传递,导致如果没有明确地声明直接依赖,则可能出现版本冲突。BOM可以直接声明版本,以便预防出现上述情况
2 ) 可以不用再为每个spring 构件写版本了
<!-- https://mvnrepository.com/artifact/org.springframework/spring-framework-bom -->
<dependencyManagement>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>5.1.8.RELEASE</version>
<type>pom</type>
</dependency>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
</dependencies>