zoukankan
html css js c++ java
SpringBoot高级-自动配置之@EnableAutoConfiguration注解
前言:通过之前的自动配置原理相关介绍的文章,我们对自动配置的流程大概都很清楚了,这里我们对 @EnableAutoConfiguration 注解的实现流程进行跟踪,发掘源码中实现的原理。
一、查看@EnableAutoConfiguration 注解的定义
二、查看@Import导入的ImportSelector接口实现类 AutoConfigurationImportSelector
三、查看实现类 AutoConfigurationImportSelector 的 selectImports() 方法
四、查看 selectImports() 方法,发现其调用了 getAutoConfigurationEntry() 方法
五、查看 getAutoConfigurationEntry() 方法, 发现其调用了 getCandidateConfigurations() 方法
六、查看 getCandidateConfigurations() 方法
断点调试,发现list对象configurations会有117个元素,这些元素就是Bean对象的全限定类名,通过对象的全限定类名将Bean初始化到IOC容器中
在断言中,有一段提示信息"No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct."
找到 spring.factories 文件的位置
打开该文件,注意“”的使用说明。列表中,就有我们熟悉 RestTemplateAutoConfiguration、EmbeddedWebServerFactoryCustomizerAutoConfiguration 等自动配置类
最后,打开一个EmbeddedWebServerFactoryCustomizerAutoConfiguration 看一看
小结:虽然由于@EnableAutoConfiguration 注解的使用,初始化了spring.factories文件列表中的配置类,但是这些配置类中,使用了Condition条件,必须满足Condition条件,才能最终将Bean初始化。
查看全文
相关阅读:
Importing multi-valued field into Solr from mySQL using Solr Data Import Handler
VMware Workstation 虚拟机使用无线wifi上网配置
Linux开发黑客
GitHub 使用说明
虹软人脸检测和识别C#
C#将结构体和指针互转的方法
笔记本电脑连接wifi,同时提供热点wifi给手机使用
基于STM32L4的开源NBIOT开发资料
ESP8266擦除工具完整安装
开发快平台(M302I小e开发板系列教程)
原文地址:https://www.cnblogs.com/elnimo/p/13792568.html
最新文章
File /hbase/.tmp/hbase.version could only be replicated to 0 nodes instead of minReplication (=1).
<aop:aspectj-autoproxy />作用
MapReduce处理HBase出错:XXX.jar is not a valid DFS filename
invalid bound statement (not found)解决办法
Spring Boot【快速入门】
Hadoop2.7.3+HBase1.2.5+ZooKeeper3.4.6搭建分布式集群环境
一淘商品类目预测[转载]
python matplotlib
solr python客户端
ElasticSearch + Kibana
热门文章
openCV_java Canny边缘检测
openCV_java 图像二值化
架构 | 京东商品搜索架构设计
互联网公司的技术博客汇总-阿里腾讯百度等
长沙互联网技术类岗位薪酬分析报告
Java线程与Linux内核线程的映射关系[转]
内容的分类和标签
分布式配置中心
Zookeeper开源客户端框架Curator简介[转]
Solr DataImportHandler
Copyright © 2011-2022 走看看