Maven依赖管理


使用Maven管理项目依赖的一大好处就是能够方便的进行依赖版本管理,但是dependencyManagementdependencies的概念有点混淆,今天把它弄清楚了,记录一下。

1
2
3
4
5
6
7
8
9
10
11
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

dependencyManagement中的依赖不会被子模块继承,仅仅是为了进行版本管理,子模块需要引入groupIdartifactId,如果也引入了version则以子模块为主,类似重写的概念。

1
2
3
4
5
6
7
8
9
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>

在主模块dependencies下的依赖会直接被子模块继承,如果你的子模块需要依赖一个公共的库可以加在这里方便管理。

-------------本文结束,感谢您的阅读-------------

本文标题:Maven依赖管理

文章作者:饭饭君~

发布时间:2019年04月20日 - 14:50

最后更新:2019年04月23日 - 11:40

原始链接:https://yangcf.github.io/2019/04/20/Maven依赖管理/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

如果我的文章有帮助到你,欢迎打赏~~
0%