Spring Boot在进行SpringApplication对象实例化时会加载META-INF/spring.factories文件,将该配置文件中的配置载入到Spring容器。

1.1.1.   Maven下载源码

通过 dependency:sources 该命令可以下载该项目中所有的依赖的包的源码。

1.1.2.   源码分析

org.springframework.boot.SpringApplication:

org.springframework.core.io.support.SpringFactoriesLoader:

由此可见,读取该配置文件来加载内容。

1.1.3.   Spring.factories文件

 # Initializers

 org.springframework.context.ApplicationContextInitializer=\

 org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer,\

 org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer

 # Application Listeners

 org.springframework.context.ApplicationListener=\

 org.springframework.boot.autoconfigure.BackgroundPreinitializer

 # Auto Configuration Import Listeners

 org.springframework.boot.autoconfigure.AutoConfigurationImportListener=\

 org.springframework.boot.autoconfigure.condition.ConditionEvaluationReportAutoConfigurationImportListener

 # Auto Configuration Import Filters

 org.springframework.boot.autoconfigure.AutoConfigurationImportFilter=\

 org.springframework.boot.autoconfigure.condition.OnClassCondition

 # Auto Configure

 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.cloud.CloudAutoConfiguration,\

 org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration,\

 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.CassandraRepositoriesAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.ldap.LdapDataAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.solr.SolrRepositoriesAutoConfiguration,\

 org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration,\

 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.jest.JestAutoConfiguration,\

 org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration,\

 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.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.flyway.FlywayAutoConfiguration,\

 org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration,\

 org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration,\

 org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration,\

 org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration,\

 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.mobile.DeviceResolverAutoConfiguration,\

 org.springframework.boot.autoconfigure.mobile.DeviceDelegatingViewResolverAutoConfiguration,\

 org.springframework.boot.autoconfigure.mobile.SitePreferenceAutoConfiguration,\

 org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration,\

 org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration,\

 org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration,\

 org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,\

 org.springframework.boot.autoconfigure.reactor.ReactorAutoConfiguration,\

 org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration,\

 org.springframework.boot.autoconfigure.security.SecurityFilterAutoConfiguration,\

 org.springframework.boot.autoconfigure.security.FallbackWebSecurityAutoConfiguration,\

 org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration,\

 org.springframework.boot.autoconfigure.sendgrid.SendGridAutoConfiguration,\

 org.springframework.boot.autoconfigure.session.SessionAutoConfiguration,\

 org.springframework.boot.autoconfigure.social.SocialWebAutoConfiguration,\

 org.springframework.boot.autoconfigure.social.FacebookAutoConfiguration,\

 org.springframework.boot.autoconfigure.social.LinkedInAutoConfiguration,\

 org.springframework.boot.autoconfigure.social.TwitterAutoConfiguration,\

 org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration,\

 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.DispatcherServletAutoConfiguration,\

 org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration,\

 org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration,\

 org.springframework.boot.autoconfigure.web.HttpEncodingAutoConfiguration,\

 org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration,\

 org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration,\

 org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration,\

 org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration,\

 org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration,\

 org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration,\

 org.springframework.boot.autoconfigure.websocket.WebSocketMessagingAutoConfiguration,\

 org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration

 # Failure analyzers

 org.springframework.boot.diagnostics.FailureAnalyzer=\

 org.springframework.boot.autoconfigure.diagnostics.analyzer.NoSuchBeanDefinitionFailureAnalyzer,\

 org.springframework.boot.autoconfigure.jdbc.DataSourceBeanCreationFailureAnalyzer,\

 org.springframework.boot.autoconfigure.jdbc.HikariDriverConfigurationFailureAnalyzer

 # Template availability providers

 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.JspTemplateAvailabilityProvider

1.1.4.   举例:Redis的自动配置

从上述的配置中可以看出,org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration是Redis的自动配置。

内容:

1.1.5.   条件注解

Spring Boot的自动配置的原理的更多相关文章

  1. Spring Boot的自动配置的原理浅析

    一.原理描述 Spring Boot在进行SpringApplication对象实例化时会加载META-INF/spring.factories文件,将该配置文件中的配置载入到Spring容器. 二. ...

  2. Spring boot 的自动配置

    Xml 配置文件 日志 Spring Boot对各种日志框架都做了支持,我们可以通过配置来修改默认的日志的配置: #设置日志级别 logging.level.org.springframework=D ...

  3. Spring Boot的自动配置原理及启动流程源码分析

    概述 Spring Boot 应用目前应该是 Java 中用得最多的框架了吧.其中 Spring Boot 最具特点之一就是自动配置,基于Spring Boot 的自动配置,我们可以很快集成某个模块, ...

  4. 了解Spring Boot的自动配置

    摘自:https://www.jianshu.com/p/ddb6e32e3faf Spring Boot的自动配置给开发者带来了很大的便利,当开发人员在pom文件中添加starter依赖后,mave ...

  5. Spring Boot的自动配置

    Spring Boot的自动配置 --摘自https://www.hollischuang.com/archives/1791 随着Ruby.Groovy等动态语言的流行,相比较之下Java的开发显得 ...

  6. 初识Spring Boot框架(二)之DIY一个Spring Boot的自动配置

    在上篇博客初识Spring Boot框架中我们初步见识了SpringBoot的方便之处,很多小伙伴可能也会好奇这个Spring Boot是怎么实现自动配置的,那么今天我就带小伙伴我们自己来实现一个简单 ...

  7. spring boot 系列之六:深入理解spring boot的自动配置

    我们知道,spring boot自动配置功能可以根据不同情况来决定spring配置应该用哪个,不应该用哪个,举个例子: Spring的JdbcTemplate是不是在Classpath里面?如果是,并 ...

  8. Spring Boot 排除自动配置的 4 种方法,关键时刻很有用!

    Spring Boot 提供的自动配置非常强大,某些情况下,自动配置的功能可能不符合我们的需求,需要我们自定义配置,这个时候就需要排除/禁用 Spring Boot 某些类的自动化配置了. 比如:数据 ...

  9. 自定义spring boot的自动配置

    文章目录 添加Maven依赖 创建自定义 Auto-Configuration 添加Class Conditions 添加 bean Conditions Property Conditions Re ...

随机推荐

  1. sails ORM组件 Waterline v0.10 英文文档

    http://sailsdoc.swift.ren/ 这里有 sails中文文档 Introduction Installation Getting Started Models Data types ...

  2. web.xml中的元素

    error-page元素包含三个子元素error-code,exception-type和location.将错误代码(Error Code)或异常(Exception)的种类对应到web应用资源路径 ...

  3. POJ3176:Cow Bowling(数字三角形问题)

    地址:http://poj.org/problem?id=3176 题目解析:没什么好说的,之前上课时老师讲过.从下往上找,每一个三角形的顶点可由两个角加上顶点的值 两种方式得到 ,用dp数组保存下最 ...

  4. sql中表级约束和列级约束

    sql中表级约束和列级约束,在SQL SERVER中, (1) 对于基本表的约束分为列约束和表约束约束是限制用户输入到表中的数据的值的范围,一般分为列级约束与表级约束.列级约束有六种:主键Primar ...

  5. $digest / $apply digest in progress报错

    有的时候出于某种原因,如jq操作了model.或者$watch.setTimeout等函数改变了model,导致最后没有脏数据检测.所以我没就手动调用了$apply( )等.但是第一次运行的时候ang ...

  6. ISAP模板

    #include<bits/stdc++.h> using namespace std; using namespace std; typedef long long ll; const ...

  7. 【Unity3D】使用MD5值,确保本地Sqlite数据库内容没有被篡改

    Sqlite的应用场景 在判断是否使用存储格式为Sqlite模式的标准,我们的标准是内容只读.也就是说,除非发布者修改Sqlite内容,玩家只有读取的权限. 换个角度说,Sqlite里面的数据都是游戏 ...

  8. 《UML和模式应用》读书笔记(一)面向对象分析和设计简单示例

    在开始进行对象分析和设计之前,先通过“扔骰子”这个软件(游戏者扔两个骰子,如果总是是7,则赢,否则输),来简单分析下这个过程. 1:用例 需求分析,可能包括人们如何应用的场景或情节,这些都可以被编写成 ...

  9. Windows 配置安卓环境变量

    变量名:JAVA_HOME 变量值:JDK 路径 变量名:CLASSPATH 变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\toos.jar      // ...

  10. 对称加密与非对称加密,以及RSA的原理

    一 , 概述 在现代密码学诞生以前,就已经有很多的加密方法了.例如,最古老的斯巴达加密棒,广泛应用于公元前7世纪的古希腊.16世纪意大利数学家卡尔达诺发明的栅格密码,基于单表代换的凯撒密码.猪圈密码, ...