Spring Boot 版本: 2.1.4.RELEASE
简要说明
Spring Boot依赖项管理定义:
Spring Boot中在spring-boot-dependencies*.jar的pom.xml中定义了所依赖的依赖项的名称和版本信息.(如果要覆盖Spring Boot默认引用的版本信息,可以在自己的pom.xml文件中定义与spring-boot-dependencies中的pom.xml中版本名称一致的配置,配置自己的版本号即可.)
pom.xml所在网址:
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-dependencies/pom.xml
替换Spring Boot配置的默认Thymeleaf版本
<properties> <!-- 省略上面的版本定义... --> <thymeleaf.version>3.0.11.RELEASE</thymeleaf.version> <thymeleaf-extras-springsecurity.version>3.0.4.RELEASE</thymeleaf-extras-springsecurity.version> <thymeleaf-layout-dialect.version>2.4.1</thymeleaf-layout-dialect.version> <thymeleaf-extras-data-attribute.version>2.0.1</thymeleaf-extras-data-attribute.version> <thymeleaf-extras-java8time.version>3.0.4.RELEASE</thymeleaf-extras-java8time.version> <!-- 省略下面的版本定义...end --> </properties>
替换thymeleaf的版本,在自己的pom.xml文件中定义:
<properties> <!-- 省略上面的版本定义...下面是示例版本号,实际可能并不存在5.X版本的信息 --> <thymeleaf.version>5.0.11.RELEASE</thymeleaf.version> <!-- 省略下面的版本定义...end --> </properties>
起步依赖的特点
- 直接面向功能;
- 一站获取所有相关依赖,不再复制粘贴
官方的Starters
命名: spring-boot-starter-*
起步依赖实现原理
其实质就是通过Maven依赖管理来实现起步依赖.
例如:要使用jdbc,只需要引入:spring-boot-starter-jdbc,而spring-boot-starter-jdbc的pom.xml文件是如下定义的:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starters</artifactId> <version>${revision}</version> </parent> <artifactId>spring-boot-starter-jdbc</artifactId> <name>Spring Boot JDBC Starter</name> <description>Starter for using JDBC with the HikariCP connection pool</description> <properties> <main.basedir>${basedir}/../../..</main.basedir> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>com.zaxxer</groupId> <artifactId>HikariCP</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> </dependency> </dependencies> </project>
也就是Spring Boot在Maven的pom.xml文件里面引入了我们自己之前需要引入的Maven依赖.
继承关系
spring-boot-starter-jdbc继承了spring-boot-starters;
而spring-boot-starters继承了spring-boot-parent;
而spring-boot-parent继承了spring-boot-dependencies;
spring-boot-dependencies继承了spring-boot-build.
继承关系如下图(最上面是最底层的):