maven中dependencymanagement的作用
dependencymanagement通常存在于父项目的pom.xml文件中,提供了一种管理依赖版本号的方式。
使用pom.xml 中的dependencyManagement 元素能让子项目中引用依赖时不需要注明版本号。Maven会沿着父子层级向上寻找dependencyManagement元素,使用它指定的版本号。
父项目的pom.xml文件
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-starter-webartifactId> <version>1.2.3.RELEASEversion> dependency> dependencies> dependencyManagement>
子项目的pom.xml文件
<dependency> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-starter-webartifactId> dependency>
如果想要切换版本号只需要将父项目的pom文件修改即可,不需要逐个修改子项目,大大提高了效率。