一、介绍与定义

本章用于记录自定义Springboot-starter的学习过程。

在我们自定义starter之前,我们首先观察一下SpringBoot自身的starter的形式都是什么样的。我们以spring-boot-starter-web为例。

Spring-boot-starter-web

通过spring-boot-starter-web,可以看出当前引入的依赖是空的JAR文件。它的作用是仅提供辅助依赖管理,这些依赖可用于自动装配或者其他类库。继续点入,可以看见其引入了spring-boot-starter,再进一步点入,又能看见其引入了spring-boot-autoconfigure

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<!-- 在spring-boot-starter-web中引入了以下依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.4.0</version>
<scope>compile</scope>
</dependency>
<!-- 在spring-boot-starter中引入了以下依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.4.0</version>
<scope>compile</scope>
</dependency>