一、版本仲裁中心
pom.xml有以下内容
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
spring-boot-starter-parent是SpringBoot的版本仲裁中心
以后我们导入依赖默认是不需要写版本,由spring-boot-starter-parent决定好了;(没有在dependencies里面管理的依赖自然需要声明版本号)
点进spring-boot-starter-parent会看到org.springframework.boot
点进org.springframework.boot会发现里面所有的版本锁定(Maven版本锁定)
所以说,只要里面有的,引入依赖就不需要引入版本号,spring-boot-starter-parent已经锁定(下面的各类启动就不需要版本号)
二、启动器
SpringBoot将所有的功能场景都抽取出来,做成一个个的starters(启动器),只需要在项目里面引入这些starter相关场景的所有依赖都会导入进来。要用什么功能就导入什么场景的启动器
在pom.xml引入web模块的功能的依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
spring-boot-starter-web启动器:帮我们导入了web模块正常运行所依赖的组件
需要什么启动器,到自己引入依赖就可以使用,版本号已经由仲裁决定了,无须引入,下图是官网看到的启动器
三、自动打包
pom.xml文件引入插件,自动打包功能,SpringBoot支持jar包运行
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
maven运行打包,将在target目录生成项目的jar
将文件copy到本地目录,用cmd的java -jar xxx.jar运行jar
jar运行测试(jar,项目里面写了个controller)