如何理解Spring Boot中的starter?
面试starter就是一组依赖的集合引入一个starter就相当于引入了这一组依赖简化依赖管理。比如spring-boot-starter-web包含了json、tomcat、spring-webmvc等多个依赖。如何自定starter?创建自动配置类即选择将哪些对象比如连接客户端注入到Spring容器中。ConfigurationpublicclassJedisAutoConfiguration{BeanpublicMyServicemyService(JedisPropertiesproperties){returnnewJedis(properties);}}创建属性类加载使用者自定义的属性进来username、passwordConfigurationProperties(jedis)publicclassJedisProperties{privateStringusername;privateStringpassword;}创建spring.factories文件即使用者的Spring容器初始化时会将我们的自动配置类加载进去。在resources/META-INF目录下创建spring.factories文件内容如下org.springframework.boot.autoconfigure.EnableAutoConfiguration\com.example.JedisAutoConfiguration使用者引入依赖使用者引入我们自定义的starter依赖。