maven-dependency与dependencyManagement的区别
作者:互联网
<!-- 子模块继承之后,提供作用:锁定版本 + 子modlue不用写groupId和version -->
<dependencyManagement>
<dependencies>
<!-- 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>
<!--spring cloud alibaba 2.1.0-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.1.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis.spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
- dependencyManagement只是声明依赖,不会下载依赖,主要作用是:管理项目依赖
- 如果dependencies里的dependency没有version元素,会寻找dependencyManagement标签里的依赖申明
- 如果dependencies里的dependency有version元素,就使用dependency中的version元素
- 子项目会全部继承夫项目中的dependencies元素
- dependencyManagement只有在子项目中写了该依赖项,并且没有指定具体版本,才会从父项目中继承该项
标签:dependencyManagement,spring,boot,maven,dependency,version,dependencies,org,cloud 来源: https://www.cnblogs.com/a999/p/15904818.html