1、 依赖管理
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.8</version>
</parent>
他的父项目
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.4.8</version>
</parent>
父项目spring-boot-dependencies
中几乎声明了所有开发中常用依赖的版本
依赖版本
springboot自动版本仲裁,图片中只截取了相关的version,依赖在下半部分,图片太大所以没有截取。以mysql为例,如果我们想引入mysql
image.png
我们可以先在
spring-boot-depenencies
里查看是否有mysql的依赖,再看这个版本是不是我们所需要的,如果是的话,我们可以直接在自己的项目中引入而无需添加版本号
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
在项目依赖中我们就能看到它被引入进来了
image.png
2、版本仲裁
如果该版本不是我们需要的,那么我们依旧引入该依赖,并添加自己的版本覆盖spring-boot-depenencies
,maven会采取就近优先原则进行加载
<properties>
<mysql.version>5.1.43</mysql.version>
</properties>
image.png
此时再看项目依赖,版本已经更换
image.png
3、starter场景启动器
1、spring-boot-starter-:就是某种场景
2、只要引入starter,这个场景的所有常规需要引入的依赖我们都自动引入
3、springboot支持的场景springboot支持的starter
4、见到*-spring-boot-starter:一般是第三方提供的开发场景启动器
5、所有场景启动器最底层的依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.3.4.RELEASE</version>
</dependency>