初识SpringBoot Starter

什么是Starterstarter 是springboot 的核心,每个starter负责实现特定的功能,使用者只需引入starter即可自动配置,无需关心框架整合带来的问题 。
Starter 项目结构src |- main|- JAVA|- resources|- META-INF|--spring.factoriespom.xmlspring.factories
## Initializers## ApplicationContextInitializer接口的作用是可以在ApplicationContext初始化之前,对Spring上下文属性进行修改,既refresh()前的一个钩子函数 。org.springframework.context.ApplicationContextInitializer## Application Listeners## ApplicationListener 是Spring的监听器,可以通过对Spring上下文发送消息事件(由ApplicationContext. publishEvent进行消息发送),由对应的监听器进行捕获处理 。org.springframework.context.ApplicationListener## Auto Configuration Import Listeners## 当Spring使用ConfigurationClassParser加载完所有@Configuration后会再一次使用AutoConfigurationImportSelector排除所有不符合条件的@Configuration,排除完后则回调所有AutoConfigurationImportListener的监听器 。可相当于加载并过滤完@Configuration后的钩子回调 。org.springframework.boot.autoconfigure.AutoConfigurationImportListener# Auto Configuration Import Filters# 为 org.springframework.boot.autoconfigure.EnableAutoConfiguration定义的所有配置类增加ImportFilter来决定是否进行配置org.springframework.boot.autoconfigure.AutoConfigurationImportFilter# Auto Configure# 定义自动装配config类,当系统引入该jar包时,spring上下文将初始化这些config类org.springframework.boot.autoconfigure.EnableAutoConfiguration# Failure analyzers# 当spring bean的调用方法抛出特定异常时由自定义的特定FailureAnalyzer进行捕获并且进行处理 。org.springframework.boot.diagnostics.FailureAnalyzerpom.xml
之后的章节中只写<dependencies> 节点
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.4.RELEASE</version></parent><modelVersion>4.0.0</modelVersion><name>demo-spring-boot-starter</name><groupId>com.v5ba</groupId><artifactId>demo-spring-boot-starter</artifactId><version>1.0-SNAPSHOT</version><packaging>jar</packaging><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency></dependencies></project>官方starter