SpringBoot的pom详解
以我本地的项目pom为例,来进行解释:
SpringBoot项目的父项目
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
SpringBoot项目的父项目的父项目
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.5.3</version>
</parent>
该依赖是真正管理Spring Boot应用里面的所有依赖版本,也称为Spring Boot的版本仲裁中心,因此,以后导入依赖默认是不需要写版本;(没有在dependencies里面管理的依赖自然需要声明版本号)
导入的依赖spring-boot-starter-web
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
spring-boot-starter
:场景应用启动器;帮我们导入了web模块正常运行所依赖的组件;
Spring boot将所有的功能场景都抽取出来,做成一个个starters(启动器),只需要在项目里面引用这些starter相关场景的所有依赖都会导入进来。要用什么功能就导入什么场景的启动器