<!--dependencyManagement提供一种管理依赖版本好的方式-->
<!-- 通常出现在项目的最顶层父POM,-->
<!-- 可以让所有在子项目中引用的依赖而不显式的列出版本好,maven会沿着父子层次向上
,直到找到一个拥有dependencyManagement元素的项目,然后就会使用这个元素里面指定的版本-->
<!-- 好处:多个子项目都引用一个依赖,避免每个子项都声明一个版本号,想升级,直接父类修改即可
,某个子项目需要更新,声明version就可以-->
<!-- 注意:dependencyManagement只是声明依赖,并不实现引入,因此子项目需要显示声明需要用的依赖-->
<!-- 子项目不引入,是不会继承父依赖和引入的-->
<!-- 注意时type为pom才不引入-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</dependency>
<!--spring boot 2.2.2-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--spring cloud Hoxton.SR1-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis.spring.boot.version}</version>
</dependency>
<!--junit-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<!--log4j-->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
public class MavenTest {
/**scope控制dependency元素的使用范围
* 默认-complie:
* 被依赖项目需要参与到编译,测试,打包,运行阶段,打包通常包含依赖项目
*
* provided:
* 参与到编译,测试,运行,但是打包时进行了exclude动作
* 例子:web项目编译可能需要servlet-api.jar.但运行的时候不需要,因为时应用服务器提供了
* runtime:
* 无需参与到项目的编译,但会参与到测试和运行阶段
* 例子:编译时不需要JDBC-API.jar,运行的时候需要
* test:
* 仅参与到测试阶段
* system:
* 与provide类似,但是被依赖项不会从maven参考查找依赖,而是本地系统获取,需要指定systemPath指定路径
* import:
* 只使用在denpendencyManagement中,且type为pom类型
* dependencyManagement里面的配置不会实际引入,只为了版本管理,
*
*/
}