SpringBoot官网描述了SpringBoot这么一个特点:
Provide opinionated ‘starter’ dependencies to simplify your build configuration(提供自动的starter依赖,以简化构建配置)。
进入SpringBoot的参考文档,我们继续来了解下starter。
可以看到,SpingBoot中有很多启动器,spring-boot-starter-*
,不同的开发场景会使用不同的启动器。比如,spring-boot-starter-web,用来构建web应用;spring-boot-starter-test,测试用;spring-boot-starter-cache,缓存用,等等。其中,spring-boot-starter是所有启动器底层的、核心的依赖。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.6.1</version>
<scope>compile</scope>
</dependency>
只要引入spring-boot-starter-*
,这个场景的所有常规需要的依赖都会自动引入。
spring-boot-starter-*
,都是Spring官网提供的stater。如果是第三方开发的启动器,通常命名为*-spring-boot-starter
。