SpringBoot系列:starters介绍
软件环境
- Spring Boot 2.0.4.RELEASE
- JDK 1.8.0_181
- Maven 3.5.4
- IntelliJ IDEA 2018.1.6
概念
Starters are a set of convenient dependency descriptors that you can include in your application. You get a one-stop shop for all the Spring and related technologies that you need without having to hunt through sample code and copy-paste loads of dependency descriptors. For example, if you want to get started using Spring and JPA for database access, include the spring-boot-starter-data-jpa dependency in your project.
大概意思就是对某一类jar依赖的合成,下面举例说明
比如我们需要使用spring-data-redis
传统办法
- 在maven项目的pom.xml文件中添加redis.clients:jedis
- 在maven项目的pom.xml文件中添加org.springframework.data:spring-data-redis
- 还需要编写application-redis.xml配置文件
- 反复调试直到可以正确运行
- 每次创建新项目都需要把以上步骤重复一遍
使用starters
- 所有相关的依赖包都会自动引入
- 只需要在application.yml中配置一些必要是信息,比如,redis的IP地址,端口等