首页 > 其他分享 >【SpringCloud】扩展——DependencyManagement和Dependencies

【SpringCloud】扩展——DependencyManagement和Dependencies

时间:2022-10-05 08:11:21浏览次数:56  
标签:DependencyManagement 模块 SpringCloud dependencyManagement Dependencies dependenci

 

Maven使用 dependencyManagement 和 dependencies 进行包的管理,它们有什么联系和区别呢?

 dependencyManagement 里只是在父项声明依赖; dependencies 引入依赖,并且子模块会继承父项中的依赖。通常, dependencyManagement 用在顶级父项中, dependencies 用在各个模块中。

使用 dependencyManagement 的好处是统一版本号管理,父pom中如下:

 1   <modules>
 2         <module>module1</module>
 3     </modules>
 4 
 5     <properties>
 6             <spring-version>3.1.1.RELEASE</spring-version>
 7     </properties>
 8 
 9     <dependencyManagement>
10           <dependency>
11                 <groupId>org.springframework</groupId>
12                 <artifactId>spring-web</artifactId>
13                 <version>${spring-version}</version>
14           </dependency>
15     </dependencyManagement>

子模块module1中dependency声明如下所示:

1 <dependencies>
2             <dependency>
3                   <groupId>org.springframework</groupId>
4                   <artifactId>spring-web</artifactId>
5             </dependency>
6     </dependencies>

 

标签:DependencyManagement,模块,SpringCloud,dependencyManagement,Dependencies,dependenci
From: https://www.cnblogs.com/luyj00436/p/16755010.html

相关文章