diff --git a/README.md b/README.md index 18eebca..352114e 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ 1. [\[2021-10-22\] Spring 源码解析十一:Spring 的扩展加载机制](spring/11.md) 1. [\[2021-10-25\] Spring 源码解析十二:SpringBoot 的加载机制](spring/12.md) 1. [\[2021-10-25\] Spring 源码解析十三:SpringBoot 初始化应用时就加载的组件](spring/13.md) +1. [\[2021-10-26\] Spring 源码解析十四:SpringBoot Autoconfigure 初始化应用时就加载的组件](spring/14.md) ## 前端进阶 diff --git a/spring/12.md b/spring/12.md index e4ebc0a..ad906ce 100644 --- a/spring/12.md +++ b/spring/12.md @@ -397,7 +397,9 @@ public class SpringApplication { ## 6. AnnotationConfigServletWebServerApplicationContext [AnnotationConfigServletWebServerApplicationContext](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContext.java) -是 SpringBoot 默认使用应用上下文,先看看继承关系 +是 SpringBoot 默认使用应用上下文 + +先看看继承关系 ``` - GenericWebApplicationContext diff --git a/spring/14.md b/spring/14.md new file mode 100644 index 0000000..2496316 --- /dev/null +++ b/spring/14.md @@ -0,0 +1,941 @@ +# Spring 源码解析十四:SpringBoot Autoconfigure 初始化应用时就加载的组件 + +这些组件定义在 [spring.factories](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories) +中 + +```properties +# 初始化器 +org.springframework.context.ApplicationContextInitializer=\ +org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer,\ +org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener + +# 应用事件监听器 +org.springframework.context.ApplicationListener=\ +org.springframework.boot.autoconfigure.BackgroundPreinitializer + +# 自动配置导入监听器 +org.springframework.boot.autoconfigure.AutoConfigurationImportListener=\ +org.springframework.boot.autoconfigure.condition.ConditionEvaluationReportAutoConfigurationImportListener + +# 自动配置导入过滤器 +org.springframework.boot.autoconfigure.AutoConfigurationImportFilter=\ +org.springframework.boot.autoconfigure.condition.OnBeanCondition,\ +org.springframework.boot.autoconfigure.condition.OnClassCondition,\ +org.springframework.boot.autoconfigure.condition.OnWebApplicationCondition + +# 自动配置 +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration,\ +org.springframework.boot.autoconfigure.aop.AopAutoConfiguration,\ +org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration,\ +org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration,\ +org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration,\ +org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration,\ +org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration,\ +org.springframework.boot.autoconfigure.context.LifecycleAutoConfiguration,\ +org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration,\ +org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration,\ +org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration,\ +org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRestClientAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration,\ +org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration,\ +org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\ +org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration,\ +org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration,\ +org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration,\ +org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration,\ +org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration,\ +org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration,\ +org.springframework.boot.autoconfigure.hazelcast.HazelcastJpaDependencyAutoConfiguration,\ +org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration,\ +org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration,\ +org.springframework.boot.autoconfigure.influx.InfluxDbAutoConfiguration,\ +org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration,\ +org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration,\ +org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\ +org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\ +org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration,\ +org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration,\ +org.springframework.boot.autoconfigure.jdbc.XADataSourceAutoConfiguration,\ +org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration,\ +org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration,\ +org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration,\ +org.springframework.boot.autoconfigure.jms.JndiConnectionFactoryAutoConfiguration,\ +org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration,\ +org.springframework.boot.autoconfigure.jms.artemis.ArtemisAutoConfiguration,\ +org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration,\ +org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration,\ +org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration,\ +org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration,\ +org.springframework.boot.autoconfigure.availability.ApplicationAvailabilityAutoConfiguration,\ +org.springframework.boot.autoconfigure.ldap.embedded.EmbeddedLdapAutoConfiguration,\ +org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration,\ +org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration,\ +org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration,\ +org.springframework.boot.autoconfigure.mail.MailSenderValidatorAutoConfiguration,\ +org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration,\ +org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration,\ +org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration,\ +org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration,\ +org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration,\ +org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,\ +org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration,\ +org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration,\ +org.springframework.boot.autoconfigure.r2dbc.R2dbcTransactionManagerAutoConfiguration,\ +org.springframework.boot.autoconfigure.rsocket.RSocketMessagingAutoConfiguration,\ +org.springframework.boot.autoconfigure.rsocket.RSocketRequesterAutoConfiguration,\ +org.springframework.boot.autoconfigure.rsocket.RSocketServerAutoConfiguration,\ +org.springframework.boot.autoconfigure.rsocket.RSocketStrategiesAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.rsocket.RSocketSecurityAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyAutoConfiguration,\ +org.springframework.boot.autoconfigure.sendgrid.SendGridAutoConfiguration,\ +org.springframework.boot.autoconfigure.session.SessionAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.oauth2.client.reactive.ReactiveOAuth2ClientAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.oauth2.resource.reactive.ReactiveOAuth2ResourceServerAutoConfiguration,\ +org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration,\ +org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration,\ +org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration,\ +org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\ +org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,\ +org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\ +org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.reactive.HttpHandlerAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.reactive.function.client.ClientHttpConnectorAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration,\ +org.springframework.boot.autoconfigure.websocket.reactive.WebSocketReactiveAutoConfiguration,\ +org.springframework.boot.autoconfigure.websocket.servlet.WebSocketServletAutoConfiguration,\ +org.springframework.boot.autoconfigure.websocket.servlet.WebSocketMessagingAutoConfiguration,\ +org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration,\ +org.springframework.boot.autoconfigure.webservices.client.WebServiceTemplateAutoConfiguration + +# 失败分析器 +org.springframework.boot.diagnostics.FailureAnalyzer=\ +org.springframework.boot.autoconfigure.data.redis.RedisUrlSyntaxFailureAnalyzer,\ +org.springframework.boot.autoconfigure.diagnostics.analyzer.NoSuchBeanDefinitionFailureAnalyzer,\ +org.springframework.boot.autoconfigure.flyway.FlywayMigrationScriptMissingFailureAnalyzer,\ +org.springframework.boot.autoconfigure.jdbc.DataSourceBeanCreationFailureAnalyzer,\ +org.springframework.boot.autoconfigure.jdbc.HikariDriverConfigurationFailureAnalyzer,\ +org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryBeanCreationFailureAnalyzer,\ +org.springframework.boot.autoconfigure.session.NonUniqueSessionRepositoryFailureAnalyzer + +# 检查模板可用提供器 +org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider=\ +org.springframework.boot.autoconfigure.freemarker.FreeMarkerTemplateAvailabilityProvider,\ +org.springframework.boot.autoconfigure.mustache.MustacheTemplateAvailabilityProvider,\ +org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAvailabilityProvider,\ +org.springframework.boot.autoconfigure.thymeleaf.ThymeleafTemplateAvailabilityProvider,\ +org.springframework.boot.autoconfigure.web.servlet.JspTemplateAvailabilityProvider +``` + +## 1. 初始化器 + +```properties +org.springframework.context.ApplicationContextInitializer=\ +org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer,\ +org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener +``` + +### 1.1. SharedMetadataReaderFactoryContextInitializer + +[SharedMetadataReaderFactoryContextInitializer](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/SharedMetadataReaderFactoryContextInitializer.java) +的主要功能是提供一个共享的缓存元信息读取工厂 + +```java +class SharedMetadataReaderFactoryContextInitializer + implements ApplicationContextInitializer, Ordered { + // 初始化 + @Override + public void initialize(ConfigurableApplicationContext applicationContext) { + BeanFactoryPostProcessor postProcessor = new CachingMetadataReaderFactoryPostProcessor(applicationContext); + applicationContext.addBeanFactoryPostProcessor(postProcessor); + } + + static class CachingMetadataReaderFactoryPostProcessor + implements BeanDefinitionRegistryPostProcessor, PriorityOrdered { + // 注册bean定义 + @Override + public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { + // 注册bean定义注册器 + register(registry); + // 配置 @Configuration bean + configureConfigurationClassPostProcessor(registry); + } + + // 注册bean定义注册器 + private void register(BeanDefinitionRegistry registry) { + BeanDefinition definition = BeanDefinitionBuilder + .genericBeanDefinition(SharedMetadataReaderFactoryBean.class, SharedMetadataReaderFactoryBean::new) + .getBeanDefinition(); + // 注册为 "org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory" 名字 + registry.registerBeanDefinition(BEAN_NAME, definition); + } + + // 配置 @Configuration bean + private void configureConfigurationClassPostProcessor(BeanDefinitionRegistry registry) { + try { + // 配置bean "org.springframework.context.annotation.internalConfigurationAnnotationProcessor" + configureConfigurationClassPostProcessor( + registry.getBeanDefinition(AnnotationConfigUtils.CONFIGURATION_ANNOTATION_PROCESSOR_BEAN_NAME)); + } + catch (NoSuchBeanDefinitionException ex) { + } + } + } +} +``` + +### 1.2. ConditionEvaluationReportLoggingListener + +[ConditionEvaluationReportLoggingListener](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportLoggingListener.java) +的主要功能是输出日志到文件 + +## 2. 应用事件监听器 + +```properties +org.springframework.context.ApplicationListener=\ +org.springframework.boot.autoconfigure.BackgroundPreinitializer +``` + +[BackgroundPreinitializer](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/BackgroundPreinitializer.java) +的主要功能是初始化数据转换与编码等服务 + +```java +public class BackgroundPreinitializer implements ApplicationListener { + @Override + public void onApplicationEvent(SpringApplicationEvent event) { + // ... 代码省略 + + if (event instanceof ApplicationEnvironmentPreparedEvent + && preinitializationStarted.compareAndSet(false, true)) { + performPreinitialization(); + } + if ((event instanceof ApplicationReadyEvent || event instanceof ApplicationFailedEvent) + && preinitializationStarted.get()) { + try { + preinitializationComplete.await(); + } + catch (InterruptedException ex) { + Thread.currentThread().interrupt(); + } + } + } + + // 初始化其他组件 + private void performPreinitialization() { + try { + Thread thread = new Thread(new Runnable() { + + @Override + public void run() { + // 初始化数据转换服务,DefaultFormattingConversionService + runSafely(new ConversionServiceInitializer()); + // 初始化数据验证服务,Validation.byDefaultProvider() + runSafely(new ValidationInitializer()); + // 初始化消息转换服务,AllEncompassingFormHttpMessageConverter + runSafely(new MessageConverterInitializer()); + // 初始化JSON服务,Jackson2ObjectMapperBuilder + runSafely(new JacksonInitializer()); + // 初始化字符编码服务,StandardCharsets + runSafely(new CharsetInitializer()); + preinitializationComplete.countDown(); + } + + public void runSafely(Runnable runnable) { + try { + runnable.run(); + } + catch (Throwable ex) {} + } + + }, "background-preinit"); + thread.start(); + } + catch (Exception ex) { + // ... 代码省略 + } + } + + private static class MessageConverterInitializer implements Runnable { + @Override + public void run() { + new AllEncompassingFormHttpMessageConverter(); + } + } + + private static class ValidationInitializer implements Runnable { + @Override + public void run() { + Configuration configuration = Validation.byDefaultProvider().configure(); + configuration.buildValidatorFactory().getValidator(); + } + } + + private static class JacksonInitializer implements Runnable { + @Override + public void run() { + Jackson2ObjectMapperBuilder.json().build(); + } + } + + private static class ConversionServiceInitializer implements Runnable { + @Override + public void run() { + new DefaultFormattingConversionService(); + } + } + + private static class CharsetInitializer implements Runnable { + @Override + public void run() { + StandardCharsets.UTF_8.name(); + } + } +} +``` + +## 3. 自动配置导入监听器 + +```properties +org.springframework.boot.autoconfigure.AutoConfigurationImportListener=\ +org.springframework.boot.autoconfigure.condition.ConditionEvaluationReportAutoConfigurationImportListener +``` + +[ConditionEvaluationReportAutoConfigurationImportListener](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportAutoConfigurationImportListener.java) +的主要功能是从 Report 中读取结果 + +## 4. 自动配置导入过滤器 + +```properties +org.springframework.boot.autoconfigure.AutoConfigurationImportFilter=\ +org.springframework.boot.autoconfigure.condition.OnBeanCondition,\ +org.springframework.boot.autoconfigure.condition.OnClassCondition,\ +org.springframework.boot.autoconfigure.condition.OnWebApplicationCondition +``` + +### 4.1. OnBeanCondition + +[OnBeanCondition](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java) +的主要功能是处理注解 `@ConditionalOnBean`、`@ConditionalOnMissingBean`、`@ConditionalOnSingleCandidate`,按条件动态载入 bean + +- `@ConditionOnBean` 判断条件 bean 存在,注入当下注解的 bean +- `@ConditionOnMissingBean` 判断条件 bean 不存在,才注入当下注解的 bean +- `@ConditionalOnSingleCandidate` 判断条件 bean 只能有一个实例或多个但只有一个 primary 实例,才注入当下注解的 bean + +先来看看继承关系 + +``` +- SpringBootCondition + - FilteringSpringBootCondition + - OnBeanCondition +``` + +#### 4.1.1. SpringBootCondition + +[SpringBootCondition](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/SpringBootCondition.java) +是用条件来检查组件的基础类 + +```java +public abstract class SpringBootCondition implements Condition { + // 元信息代表的组件是否匹配 + @Override + public final boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { + // 获取类名或方法名 + String classOrMethodName = getClassOrMethodName(metadata); + try { + // 获取匹配结果 + ConditionOutcome outcome = getMatchOutcome(context, metadata); + + // ... 代码省略 + + // 返回是否匹配 + return outcome.isMatch(); + } + catch (NoClassDefFoundError ex) { + // ... 代码省略 + } + + // ... 代码省略 + } + + // 获取匹配结果,由子类实现 + public abstract ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata); +} +``` + +#### 4.1.2. FilteringSpringBootCondition + +[FilteringSpringBootCondition](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/FilteringSpringBootCondition.java) +的主要功能是添加过滤功能 + +```java +abstract class FilteringSpringBootCondition extends SpringBootCondition + implements AutoConfigurationImportFilter, BeanFactoryAware, BeanClassLoaderAware { + // 元信息代表的组件是否匹配 + @Override + public boolean[] match(String[] autoConfigurationClasses, AutoConfigurationMetadata autoConfigurationMetadata) { + // 获取结果 + ConditionOutcome[] outcomes = getOutcomes(autoConfigurationClasses, autoConfigurationMetadata); + boolean[] match = new boolean[outcomes.length]; + for (int i = 0; i < outcomes.length; i++) { + // 如果返回为null或true,则表示匹配 + match[i] = (outcomes[i] == null || outcomes[i].isMatch()); + // ... 代码省略 + } + return match; + } + + // 获取结果,由子类实现 + protected abstract ConditionOutcome[] getOutcomes(String[] autoConfigurationClasses, + AutoConfigurationMetadata autoConfigurationMetadata); +} +``` + +#### 4.1.3. SpringBootCondition + +[SpringBootCondition](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/SpringBootCondition.java) +的主要功能是处理注解 `@ConditionalOnBean`、`@ConditionalOnMissingBean`、`@ConditionalOnSingleCandidate`,按条件动态载入 bean + +```java +class OnBeanCondition extends FilteringSpringBootCondition implements ConfigurationCondition { + // 获取结果 + @Override + protected final ConditionOutcome[] getOutcomes(String[] autoConfigurationClasses, + AutoConfigurationMetadata autoConfigurationMetadata) { + // 结果集 + ConditionOutcome[] outcomes = new ConditionOutcome[autoConfigurationClasses.length]; + for (int i = 0; i < outcomes.length; i++) { + // 自动配置类 + String autoConfigurationClass = autoConfigurationClasses[i]; + if (autoConfigurationClass != null) { + // 获取ConditionalOnBean的bean类型 + Set onBeanTypes = autoConfigurationMetadata.getSet(autoConfigurationClass, "ConditionalOnBean"); + // 确定有没有ConditionalOnBean的bean类型 + outcomes[i] = getOutcome(onBeanTypes, ConditionalOnBean.class); + if (outcomes[i] == null) { + // 获取ConditionalOnSingleCandidate的bean类型 + Set onSingleCandidateTypes = autoConfigurationMetadata.getSet(autoConfigurationClass, + "ConditionalOnSingleCandidate"); + // 确定有没有ConditionalOnSingleCandidate的bean类型 + outcomes[i] = getOutcome(onSingleCandidateTypes, ConditionalOnSingleCandidate.class); + } + } + } + return outcomes; + } +} +``` + +```java +class OnBeanCondition extends FilteringSpringBootCondition implements ConfigurationCondition { + // 获取匹配结果 + @Override + public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { + // 匹配信息 + ConditionMessage matchMessage = ConditionMessage.empty(); + // 元信息中的注解 + MergedAnnotations annotations = metadata.getAnnotations(); + // 有@ConditionalOnBean注解 + if (annotations.isPresent(ConditionalOnBean.class)) { + // 创建ConditionalOnBean的匹配标准对象 + Spec spec = new Spec<>(context, metadata, annotations, ConditionalOnBean.class); + // 获取匹配的bean + MatchResult matchResult = getMatchingBeans(context, spec); + // 如果一个都没有匹配到 + if (!matchResult.isAllMatched()) { + // 返回匹配不到的信息 + String reason = createOnBeanNoMatchReason(matchResult); + return ConditionOutcome.noMatch(spec.message().because(reason)); + } + // 匹配到了,继续 + matchMessage = spec.message(matchMessage).found("bean", "beans").items(Style.QUOTE, + matchResult.getNamesOfAllMatches()); + } + // 有@ConditionalOnSingleCandidate注解 + if (metadata.isAnnotated(ConditionalOnSingleCandidate.class.getName())) { + // 创建ConditionalOnSingleCandidate的匹配标准对象 + Spec spec = new SingleCandidateSpec(context, metadata, annotations); + // 获取匹配的bean + MatchResult matchResult = getMatchingBeans(context, spec); + // 如果一个都没有匹配到 + if (!matchResult.isAllMatched()) { + // 返回匹配不到的信息 + return ConditionOutcome.noMatch(spec.message().didNotFind("any beans").atAll()); + } + // 匹配到多个bean,但没有primary bean + else if (!hasSingleAutowireCandidate(context.getBeanFactory(), matchResult.getNamesOfAllMatches(), + spec.getStrategy() == SearchStrategy.ALL)) { + // 返回匹配到多个的信息 + return ConditionOutcome.noMatch(spec.message().didNotFind("a primary bean from beans") + .items(Style.QUOTE, matchResult.getNamesOfAllMatches())); + } + // 匹配到了,继续 + matchMessage = spec.message(matchMessage).found("a primary bean from beans").items(Style.QUOTE, + matchResult.getNamesOfAllMatches()); + } + // 有@ConditionalOnMissingBean注解 + if (metadata.isAnnotated(ConditionalOnMissingBean.class.getName())) { + // 创建ConditionalOnMissingBean的匹配标准对象 + Spec spec = new Spec<>(context, metadata, annotations, + ConditionalOnMissingBean.class); + // 获取匹配的bean + MatchResult matchResult = getMatchingBeans(context, spec); + // 如果匹配到了 + if (matchResult.isAnyMatched()) { + // 返回匹配到了的信息 + String reason = createOnMissingBeanNoMatchReason(matchResult); + return ConditionOutcome.noMatch(spec.message().because(reason)); + } + // 匹配不到,继续 + matchMessage = spec.message(matchMessage).didNotFind("any beans").atAll(); + } + return ConditionOutcome.match(matchMessage); + } +} +``` + +### 4.2. OnClassCondition + +[OnClassCondition](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnClassCondition.java) +的主要功能是处理注解 `@ConditionalOnClass`、`@ConditionalOnMissingClass`,按条件动态载入 bean + +- `@ConditionalOnClass` 判断条件类存在,注入当下注解的 bean +- `@ConditionalOnMissingClass` 判断条件类不存在,才注入当下注解的 bean + +```java +class OnClassCondition extends FilteringSpringBootCondition { + // 获取结果 + @Override + protected final ConditionOutcome[] getOutcomes(String[] autoConfigurationClasses, + AutoConfigurationMetadata autoConfigurationMetadata) { + // ... 代码省略 + + OutcomesResolver outcomesResolver = new StandardOutcomesResolver(autoConfigurationClasses, 0, + autoConfigurationClasses.length, autoConfigurationMetadata, getBeanClassLoader()); + // 获取ConditionalOnClass的输出 + return outcomesResolver.resolveOutcomes(); + + } + + // 获取匹配结果 + @Override + public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { + ClassLoader classLoader = context.getClassLoader(); + // 匹配信息 + ConditionMessage matchMessage = ConditionMessage.empty(); + // 获取标记有@ConditionalOnClass注解的类 + List onClasses = getCandidates(metadata, ConditionalOnClass.class); + if (onClasses != null) { + List missing = filter(onClasses, ClassNameFilter.MISSING, classLoader); + // 类不存在,返回 + if (!missing.isEmpty()) { + return ConditionOutcome.noMatch(ConditionMessage.forCondition(ConditionalOnClass.class) + .didNotFind("required class", "required classes").items(Style.QUOTE, missing)); + } + // 类存在,继续 + matchMessage = matchMessage.andCondition(ConditionalOnClass.class) + .found("required class", "required classes") + .items(Style.QUOTE, filter(onClasses, ClassNameFilter.PRESENT, classLoader)); + } + // 获取标记有@ConditionalOnMissingClass注解的类 + List onMissingClasses = getCandidates(metadata, ConditionalOnMissingClass.class); + if (onMissingClasses != null) { + List present = filter(onMissingClasses, ClassNameFilter.PRESENT, classLoader); + // 类存在,返回 + if (!present.isEmpty()) { + return ConditionOutcome.noMatch(ConditionMessage.forCondition(ConditionalOnMissingClass.class) + .found("unwanted class", "unwanted classes").items(Style.QUOTE, present)); + } + // 类不存在,继续 + matchMessage = matchMessage.andCondition(ConditionalOnMissingClass.class) + .didNotFind("unwanted class", "unwanted classes") + .items(Style.QUOTE, filter(onMissingClasses, ClassNameFilter.MISSING, classLoader)); + } + return ConditionOutcome.match(matchMessage); + } + +} +``` + +### 4.3. OnWebApplicationCondition + +[OnWebApplicationCondition](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnWebApplicationCondition.java) +的主要功能是处理注解 `@ConditionalOnWebApplication`、`@ConditionalOnNotWebApplication`,按条件动态载入 bean + +- `@ConditionalOnWebApplication` 判断应用时 Web 应用时,注入当下注解的 bean +- `@ConditionalOnNotWebApplication` 判断应用时不是 Web 应用时,才注入当下注解的 bean + +## 5. 自动配置 + +```properties +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration,\ +org.springframework.boot.autoconfigure.aop.AopAutoConfiguration,\ +org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration,\ +org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration,\ +org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration,\ +org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration,\ +org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration,\ +org.springframework.boot.autoconfigure.context.LifecycleAutoConfiguration,\ +org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration,\ +org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration,\ +org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration,\ +org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.couchbase.CouchbaseReactiveRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRestClientAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration,\ +org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration,\ +org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\ +org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration,\ +org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration,\ +org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration,\ +org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration,\ +org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration,\ +org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration,\ +org.springframework.boot.autoconfigure.hazelcast.HazelcastJpaDependencyAutoConfiguration,\ +org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration,\ +org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration,\ +org.springframework.boot.autoconfigure.influx.InfluxDbAutoConfiguration,\ +org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration,\ +org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration,\ +org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\ +org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\ +org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration,\ +org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration,\ +org.springframework.boot.autoconfigure.jdbc.XADataSourceAutoConfiguration,\ +org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration,\ +org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration,\ +org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration,\ +org.springframework.boot.autoconfigure.jms.JndiConnectionFactoryAutoConfiguration,\ +org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration,\ +org.springframework.boot.autoconfigure.jms.artemis.ArtemisAutoConfiguration,\ +org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration,\ +org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration,\ +org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration,\ +org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration,\ +org.springframework.boot.autoconfigure.availability.ApplicationAvailabilityAutoConfiguration,\ +org.springframework.boot.autoconfigure.ldap.embedded.EmbeddedLdapAutoConfiguration,\ +org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration,\ +org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration,\ +org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration,\ +org.springframework.boot.autoconfigure.mail.MailSenderValidatorAutoConfiguration,\ +org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration,\ +org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration,\ +org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration,\ +org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration,\ +org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration,\ +org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,\ +org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration,\ +org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration,\ +org.springframework.boot.autoconfigure.r2dbc.R2dbcTransactionManagerAutoConfiguration,\ +org.springframework.boot.autoconfigure.rsocket.RSocketMessagingAutoConfiguration,\ +org.springframework.boot.autoconfigure.rsocket.RSocketRequesterAutoConfiguration,\ +org.springframework.boot.autoconfigure.rsocket.RSocketServerAutoConfiguration,\ +org.springframework.boot.autoconfigure.rsocket.RSocketStrategiesAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.rsocket.RSocketSecurityAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyAutoConfiguration,\ +org.springframework.boot.autoconfigure.sendgrid.SendGridAutoConfiguration,\ +org.springframework.boot.autoconfigure.session.SessionAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.oauth2.client.reactive.ReactiveOAuth2ClientAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration,\ +org.springframework.boot.autoconfigure.security.oauth2.resource.reactive.ReactiveOAuth2ResourceServerAutoConfiguration,\ +org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration,\ +org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration,\ +org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration,\ +org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\ +org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,\ +org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\ +org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.reactive.HttpHandlerAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.reactive.ReactiveWebServerFactoryAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.reactive.function.client.ClientHttpConnectorAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration,\ +org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration,\ +org.springframework.boot.autoconfigure.websocket.reactive.WebSocketReactiveAutoConfiguration,\ +org.springframework.boot.autoconfigure.websocket.servlet.WebSocketServletAutoConfiguration,\ +org.springframework.boot.autoconfigure.websocket.servlet.WebSocketMessagingAutoConfiguration,\ +org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration,\ +org.springframework.boot.autoconfigure.webservices.client.WebServiceTemplateAutoConfiguration +``` + +- [SpringApplicationAdminJmxAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.java) +- [AopAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.java) +- [RabbitAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java) +- [BatchAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java) +- [CacheAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java) +- [CassandraAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java) +- [ConfigurationPropertiesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/ConfigurationPropertiesAutoConfiguration.java) +- [LifecycleAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/LifecycleAutoConfiguration.java) +- [MessageSourceAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfiguration.java) +- [PropertyPlaceholderAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/PropertyPlaceholderAutoConfiguration.java) +- [CouchbaseAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java) +- [PersistenceExceptionTranslationAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java) +- [CassandraDataAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.java) +- [CassandraReactiveDataAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfiguration.java) +- [CassandraReactiveRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveRepositoriesAutoConfiguration.java) +- [CassandraRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraRepositoriesAutoConfiguration.java) +- [CouchbaseDataAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataAutoConfiguration.java) +- [CouchbaseReactiveDataAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseReactiveDataAutoConfiguration.java) +- [CouchbaseReactiveRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseReactiveRepositoriesAutoConfiguration.java) +- [CouchbaseRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseRepositoriesAutoConfiguration.java) +- [ElasticsearchDataAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.java) +- [ElasticsearchRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchRepositoriesAutoConfiguration.java) +- [ReactiveElasticsearchRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRepositoriesAutoConfiguration.java) +- [ReactiveElasticsearchRestClientAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRestClientAutoConfiguration.java) +- [JdbcRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfiguration.java) +- [JpaRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/jpa/JpaRepositoriesAutoConfiguration.java) +- [LdapRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/ldap/LdapRepositoriesAutoConfiguration.java) +- [MongoDataAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.java) +- [MongoReactiveDataAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveDataAutoConfiguration.java) +- [MongoReactiveRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveRepositoriesAutoConfiguration.java) +- [MongoRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfiguration.java) +- [Neo4jDataAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java) +- [Neo4jReactiveDataAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveDataAutoConfiguration.java) +- [Neo4jReactiveRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jReactiveRepositoriesAutoConfiguration.java) +- [Neo4jRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jRepositoriesAutoConfiguration.java) +- [R2dbcDataAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/r2dbc/R2dbcDataAutoConfiguration.java) +- [R2dbcRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/r2dbc/R2dbcRepositoriesAutoConfiguration.java) +- [RedisAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java) +- [RedisReactiveAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisReactiveAutoConfiguration.java) +- [RedisRepositoriesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfiguration.java) +- [RepositoryRestMvcAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfiguration.java) +- [SpringDataWebAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/web/SpringDataWebAutoConfiguration.java) +- [ElasticsearchRestClientAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchRestClientAutoConfiguration.java) +- [FlywayAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java) +- [FreeMarkerAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java) +- [GroovyTemplateAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java) +- [GsonAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java) +- [H2ConsoleAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java) +- [HypermediaAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfiguration.java) +- [HazelcastAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfiguration.java) +- [HazelcastJpaDependencyAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfiguration.java) +- [HttpMessageConvertersAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java) +- [CodecsAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/codec/CodecsAutoConfiguration.java) +- [InfluxDbAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbAutoConfiguration.java) +- [ProjectInfoAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java) +- [IntegrationAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java) +- [JacksonAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.java) +- [DataSourceAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java) +- [JdbcTemplateAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JdbcTemplateAutoConfiguration.java) +- [JndiDataSourceAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JndiDataSourceAutoConfiguration.java) +- [XADataSourceAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/XADataSourceAutoConfiguration.java) +- [DataSourceTransactionManagerAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfiguration.java) +- [JmsAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsAutoConfiguration.java) +- [JmxAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java) +- [JndiConnectionFactoryAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JndiConnectionFactoryAutoConfiguration.java) +- [ActiveMQAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQAutoConfiguration.java) +- [ArtemisAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfiguration.java) +- [JerseyAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java) +- [JooqAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java) +- [JsonbAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jsonb/JsonbAutoConfiguration.java) +- [KafkaAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.java) +- [ApplicationAvailabilityAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/availability/ApplicationAvailabilityAutoConfiguration.java) +- [EmbeddedLdapAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java) +- [LdapAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfiguration.java) +- [LiquibaseAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java) +- [MailSenderAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfiguration.java) +- [MailSenderValidatorAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailSenderValidatorAutoConfiguration.java) +- [EmbeddedMongoAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java) +- [MongoAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java) +- [MongoReactiveAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfiguration.java) +- [MustacheAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java) +- [Neo4jAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/neo4j/Neo4jAutoConfiguration.java) +- [HibernateJpaAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.java) +- [QuartzAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java) +- [R2dbcAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/R2dbcAutoConfiguration.java) +- [R2dbcTransactionManagerAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/R2dbcTransactionManagerAutoConfiguration.java) +- [RSocketMessagingAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketMessagingAutoConfiguration.java) +- [RSocketRequesterAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketRequesterAutoConfiguration.java) +- [RSocketServerAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketServerAutoConfiguration.java) +- [RSocketStrategiesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketStrategiesAutoConfiguration.java) +- [SecurityAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfiguration.java) +- [UserDetailsServiceAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/UserDetailsServiceAutoConfiguration.java) +- [SecurityFilterAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/SecurityFilterAutoConfiguration.java) +- [ReactiveSecurityAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveSecurityAutoConfiguration.java) +- [ReactiveUserDetailsServiceAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveUserDetailsServiceAutoConfiguration.java) +- [RSocketSecurityAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/rsocket/RSocketSecurityAutoConfiguration.java) +- [Saml2RelyingPartyAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyAutoConfiguration.java) +- [SendGridAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/sendgrid/SendGridAutoConfiguration.java) +- [SessionAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration.java) +- [OAuth2ClientAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2ClientAutoConfiguration.java) +- [ReactiveOAuth2ClientAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/reactive/ReactiveOAuth2ClientAutoConfiguration.java) +- [OAuth2ResourceServerAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfiguration.java) +- [ReactiveOAuth2ResourceServerAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerAutoConfiguration.java) +- [SolrAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/SolrAutoConfiguration.java) +- [TaskExecutionAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfiguration.java) +- [TaskSchedulingAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfiguration.java) +- [ThymeleafAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java) +- [TransactionAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfiguration.java) +- [JtaAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfiguration.java) +- [ValidationAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java) +- [RestTemplateAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration.java) +- [EmbeddedWebServerFactoryCustomizerAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration.java) +- [HttpHandlerAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/HttpHandlerAutoConfiguration.java) +- [ReactiveWebServerFactoryAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfiguration.java) +- [WebFluxAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfiguration.java) +- [ErrorWebFluxAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/ErrorWebFluxAutoConfiguration.java) +- [ClientHttpConnectorAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/function/client/ClientHttpConnectorAutoConfiguration.java) +- [WebClientAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfiguration.java) +- [DispatcherServletAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java) +- [ServletWebServerFactoryAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.java) +- [ErrorMvcAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java) +- [HttpEncodingAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfiguration.java) +- [MultipartAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/MultipartAutoConfiguration.java) +- [WebMvcAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java) +- [WebSocketReactiveAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/reactive/WebSocketReactiveAutoConfiguration.java) +- [WebSocketServletAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketServletAutoConfiguration.java) +- [WebSocketMessagingAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfiguration.java) +- [WebServicesAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfiguration.java) +- [WebServiceTemplateAutoConfiguration](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/client/WebServiceTemplateAutoConfiguration.java) + +以上的类都是通过 `application*.yaml` 中的属性配置自动装载成 bean。这些类都比较简单,可以自行探索 + +## 6. 失败分析器 + +```properties +org.springframework.boot.diagnostics.FailureAnalyzer=\ +org.springframework.boot.autoconfigure.data.redis.RedisUrlSyntaxFailureAnalyzer,\ +org.springframework.boot.autoconfigure.diagnostics.analyzer.NoSuchBeanDefinitionFailureAnalyzer,\ +org.springframework.boot.autoconfigure.flyway.FlywayMigrationScriptMissingFailureAnalyzer,\ +org.springframework.boot.autoconfigure.jdbc.DataSourceBeanCreationFailureAnalyzer,\ +org.springframework.boot.autoconfigure.jdbc.HikariDriverConfigurationFailureAnalyzer,\ +org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryBeanCreationFailureAnalyzer,\ +org.springframework.boot.autoconfigure.session.NonUniqueSessionRepositoryFailureAnalyzer +``` + +- [RedisUrlSyntaxFailureAnalyzer](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisUrlSyntaxFailureAnalyzer.java) + Redis url 语法错误 +- [NoSuchBeanDefinitionFailureAnalyzer](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java) + 没有 bean 定义 +- [FlywayMigrationScriptMissingFailureAnalyzer](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayMigrationScriptMissingFailureAnalyzer.java) + Flyway 没有可用的 sql 脚本 +- [DataSourceBeanCreationFailureAnalyzer](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceBeanCreationFailureAnalyzer.java) + 数据库源 bean 创建失败 +- [HikariDriverConfigurationFailureAnalyzer](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/HikariDriverConfigurationFailureAnalyzer.java) + HikariCP 配置失败 +- [ConnectionFactoryBeanCreationFailureAnalyzer](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryBeanCreationFailureAnalyzer.java) + ConnectionFactory bean 创建失败 +- [NonUniqueSessionRepositoryFailureAnalyzer](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/NonUniqueSessionRepositoryFailureAnalyzer.java) + 多个 Spring Session 错误 + +这些类都比较简单,可以自行探索 + +## 7. 检查模板可用提供器 + +```properties +org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider=\ +org.springframework.boot.autoconfigure.freemarker.FreeMarkerTemplateAvailabilityProvider,\ +org.springframework.boot.autoconfigure.mustache.MustacheTemplateAvailabilityProvider,\ +org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAvailabilityProvider,\ +org.springframework.boot.autoconfigure.thymeleaf.ThymeleafTemplateAvailabilityProvider,\ +org.springframework.boot.autoconfigure.web.servlet.JspTemplateAvailabilityProvider +``` + +- [FreeMarkerTemplateAvailabilityProvider](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProvider.java) + FreeMarker 模板检查 +- [MustacheTemplateAvailabilityProvider](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheTemplateAvailabilityProvider.java) + Mustache 模板检查 +- [GroovyTemplateAvailabilityProvider](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAvailabilityProvider.java) + Groovy 模板检查 +- [ThymeleafTemplateAvailabilityProvider](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/themeleaf/ThymeleafTemplateAvailabilityProvider.java) + Thymeleaf 模板检查 +- [JspTemplateAvailabilityProvider](https://github.com/spring-projects/spring-boot/blob/v2.5.6/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/JspTemplateAvailabilityProvider.java) + Jsp 模板检查 + +这些类都比较简单,可以自行探索 + +## 后续 + +更多博客,查看 [https://github.com/senntyou/blogs](https://github.com/senntyou/blogs) + +作者:[深予之 (@senntyou)](https://github.com/senntyou) + +版权声明:自由转载-非商用-非衍生-保持署名([创意共享 3.0 许可证](https://creativecommons.org/licenses/by-nc-nd/3.0/deed.zh)) diff --git a/spring/6.md b/spring/6.md index 7c35f29..9a24478 100644 --- a/spring/6.md +++ b/spring/6.md @@ -70,7 +70,9 @@ org.springframework.web.servlet.FlashMapManager=org.springframework.web.servlet. ## 1. BeanNameUrlHandlerMapping [BeanNameUrlHandlerMapping](https://github.com/spring-projects/spring-framework/blob/v5.3.10/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/BeanNameUrlHandlerMapping.java) -的主要功能是映射 url 到 bean,继承关系如下 +的主要功能是映射 url 到 bean + +继承关系如下 ``` - AbstractHandlerMapping @@ -357,7 +359,9 @@ public class BeanNameUrlHandlerMapping extends AbstractDetectingUrlHandlerMappin ## 2. RequestMappingHandlerMapping [RequestMappingHandlerMapping](https://github.com/spring-projects/spring-framework/blob/v5.3.10/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java) -的主要功能是处理`@RequestMapping`与`@Controller`注解,继承关系如下 +的主要功能是处理`@RequestMapping`与`@Controller`注解 + +继承关系如下 ``` - AbstractHandlerMapping @@ -773,7 +777,9 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini `HttpRequestHandlerAdapter`与`SimpleControllerHandlerAdapter`策略比较简单,这里就不解析了 [RequestMappingHandlerAdapter](https://github.com/spring-projects/spring-framework/blob/v5.3.10/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java) -的主要功能是支持 `@RequestMapping` 定义路由适配调用,继承关系如下 +的主要功能是支持 `@RequestMapping` 定义路由适配调用 + +继承关系如下 ``` - WebContentGenerator diff --git a/spring/7.md b/spring/7.md index 66193e1..fe4f957 100644 --- a/spring/7.md +++ b/spring/7.md @@ -16,7 +16,9 @@ ## 1. ExceptionHandlerExceptionResolver [ExceptionHandlerExceptionResolver](https://github.com/spring-projects/spring-framework/blob/v5.3.10/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java) -的主要功能是解析处理器调用产生的异常,继承关系如下 +的主要功能是解析处理器调用产生的异常 + +继承关系如下 ``` - AbstractHandlerExceptionResolver @@ -538,7 +540,9 @@ public class DefaultRequestToViewNameTranslator implements RequestToViewNameTran ## 5. InternalResourceViewResolver [InternalResourceViewResolver](https://github.com/spring-projects/spring-framework/blob/v5.3.10/spring-webmvc/src/main/java/org/springframework/web/servlet/view/InternalResourceViewResolver.java) -的主要功能是把视图名字解析成视图对象,继承关系如下 +的主要功能是把视图名字解析成视图对象 + +继承关系如下 ``` - AbstractCachingViewResolver