diff --git a/docs/SpringBoot/SpringBoot-ConditionalOnBean.md b/docs/SpringBoot/SpringBoot-ConditionalOnBean.md index 1417d87..83b2387 100644 --- a/docs/SpringBoot/SpringBoot-ConditionalOnBean.md +++ b/docs/SpringBoot/SpringBoot-ConditionalOnBean.md @@ -97,7 +97,7 @@ public enum SearchStrategy { - 类图 - ![image-20200824085726621](//images/SpringBoot//SpringBoot/image-20200824085726621.png) + ![image-20200824085726621](../../images/SpringBoot//SpringBoot/image-20200824085726621.png) 在看这部分源码之前需要先了解 `Conditional`和`Condition`的源码 @@ -421,7 +421,7 @@ for (String type : spec.getTypes()) { - 在忽略 bean 找到之后做一个类型移除的操作. -![image-20200825140750035](/images/SpringBoot//image-20200825140750035.png) +![image-20200825140750035](../../images/SpringBoot//image-20200825140750035.png) ### 返回值 @@ -469,7 +469,7 @@ public static ConditionOutcome noMatch(ConditionMessage message) { return ConditionOutcome.match(matchMessage); ``` -![image-20200825141506531](/images/SpringBoot//image-20200825141506531.png) +![image-20200825141506531](../../images/SpringBoot//image-20200825141506531.png) - 到此结果封装完毕.回到方法`org.springframework.boot.autoconfigure.condition.SpringBootCondition#matches(org.springframework.context.annotation.ConditionContext, org.springframework.core.type.AnnotatedTypeMetadata)` 继续进行 - 再往后就继续执行 spring 的 bean 初始化咯 @@ -492,7 +492,7 @@ public static ConditionOutcome noMatch(ConditionMessage message) { - 根据类的注解信息我们可以找到有`ResourceBundleCondition` - ![image-20200825092343271](/images/SpringBoot//image-20200825092343271.png) + ![image-20200825092343271](../../images/SpringBoot//image-20200825092343271.png) - 获取类名或者方法名的结果是`MessageSourceAutoConfiguration`全路径 @@ -592,8 +592,8 @@ org.springframework.boot.autoconfigure.condition.OnWebApplicationCondition - 此时我们可以和前文的源码分析连接起来有一个完整的认识了 - ![image-20200825142332485](/images/SpringBoot//image-20200825142332485.png) + ![image-20200825142332485](../../images/SpringBoot//image-20200825142332485.png) - 最后来看整体类图 - ![image-20200825142418115](/images/SpringBoot//image-20200825142418115.png) + ![image-20200825142418115](../../images/SpringBoot//image-20200825142418115.png) diff --git a/docs/SpringBoot/SpringBoot-ConfigurationProperties.md b/docs/SpringBoot/SpringBoot-ConfigurationProperties.md index 9df3de5..4c569f2 100644 --- a/docs/SpringBoot/SpringBoot-ConfigurationProperties.md +++ b/docs/SpringBoot/SpringBoot-ConfigurationProperties.md @@ -33,7 +33,7 @@ public @interface ConfigurationPropertiesScan {} ## ConfigurationPropertiesScanRegistrar -![image-20200323094446756](../../../images/SpringBoot/image-20200323094446756.png) +![image-20200323094446756](../../images/SpringBoot/image-20200323094446756.png) - debug 没有抓到后续补充 @@ -137,11 +137,11 @@ public @interface EnableConfigurationProperties { - 先看输入参数 **metadata** -![image-20200323134135926](../../../images/SpringBoot/image-20200323134135926.png) +![image-20200323134135926](../../images/SpringBoot/image-20200323134135926.png) - getTypes 结果 -![image-20200323134325955](../../../images/SpringBoot/image-20200323134325955.png) +![image-20200323134325955](../../images/SpringBoot/image-20200323134325955.png) - 源码开始,先找出刚才的对象`org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration` @@ -192,7 +192,7 @@ public @interface EnableConfigurationProperties { ## ConfigurationPropertiesBindingPostProcessor -![image-20200323095626953](../../../images/SpringBoot/image-20200323095626953.png) +![image-20200323095626953](../../images/SpringBoot/image-20200323095626953.png) ### postProcessBeforeInitialization @@ -301,15 +301,15 @@ public @interface EnableConfigurationProperties { - `annotation` -![image-20200323104711545](../../../images/SpringBoot/image-20200323104711545.png) +![image-20200323104711545](../../images/SpringBoot/image-20200323104711545.png) - `bindType` -![image-20200323104815305](../../../images/SpringBoot/image-20200323104815305.png) +![image-20200323104815305](../../images/SpringBoot/image-20200323104815305.png) - 返回对象 -![image-20200323105053757](../../../images/SpringBoot/image-20200323105053757.png) +![image-20200323105053757](../../images/SpringBoot/image-20200323105053757.png) - 此时数据还没有进去 @@ -319,7 +319,7 @@ public @interface EnableConfigurationProperties { 直接看结果 -![image-20200323105155998](../../../images/SpringBoot/image-20200323105155998.png) +![image-20200323105155998](../../images/SpringBoot/image-20200323105155998.png) - 上述配置和我在配置文件中写的配置一致 @@ -362,7 +362,7 @@ BindResult bind(ConfigurationPropertiesBean propertiesBean) { } ``` -![image-20200323105830138](../../../images/SpringBoot/image-20200323105830138.png) +![image-20200323105830138](../../images/SpringBoot/image-20200323105830138.png) ##### findProperty @@ -428,11 +428,11 @@ BindResult bind(ConfigurationPropertiesBean propertiesBean) { ``` -![image-20200323115408877](../../../images/SpringBoot/image-20200323115408877.png) +![image-20200323115408877](../../images/SpringBoot/image-20200323115408877.png) -![image-20200323115701118](../../../images/SpringBoot/image-20200323115701118.png) +![image-20200323115701118](../../images/SpringBoot/image-20200323115701118.png) -![image-20200323115711826](../../../images/SpringBoot/image-20200323115711826.png) +![image-20200323115711826](../../images/SpringBoot/image-20200323115711826.png) ##### getBindHandler @@ -465,7 +465,7 @@ private BindHandler getBindHandler(Bindable target, ConfigurationProperti - 最终获取得到的处理器 -![image-20200323110603959](../../../images/SpringBoot/image-20200323110603959.png) +![image-20200323110603959](../../images/SpringBoot/image-20200323110603959.png) - 最后的 bind @@ -499,7 +499,7 @@ private BindHandler getBindHandler(Bindable target, ConfigurationProperti ``` -![image-20200323112945449](../../../images/SpringBoot/image-20200323112945449.png) +![image-20200323112945449](../../images/SpringBoot/image-20200323112945449.png) 配置信息到此绑定成功,关于如何处理集合相关的配置请各位读者自行学习 diff --git a/docs/SpringBoot/SpringBoot-LogSystem.md b/docs/SpringBoot/SpringBoot-LogSystem.md index 5738379..c3b9045 100644 --- a/docs/SpringBoot/SpringBoot-LogSystem.md +++ b/docs/SpringBoot/SpringBoot-LogSystem.md @@ -19,7 +19,7 @@ public enum LogLevel { - `org.springframework.boot.logging.java.JavaLoggingSystem` -![image-20200323144523848](../../../images/SpringBoot/image-20200323144523848.png) +![image-20200323144523848](../../images/SpringBoot/image-20200323144523848.png) ```JAVA static { @@ -128,7 +128,7 @@ public static LoggingSystem get(ClassLoader classLoader) { ``` -![image-20200323151409473](../../../images/SpringBoot/image-20200323151409473.png) +![image-20200323151409473](../../images/SpringBoot/image-20200323151409473.png) - 默认日志: `org.springframework.boot.logging.logback.LogbackLoggingSystem` @@ -136,7 +136,7 @@ public static LoggingSystem get(ClassLoader classLoader) { - 初始化之前 - ![image-20200323154205484](../../../images/SpringBoot/image-20200323154205484.png) + ![image-20200323154205484](../../images/SpringBoot/image-20200323154205484.png) - 链路 1. `org.springframework.boot.context.logging.LoggingApplicationListener#onApplicationEvent` @@ -352,9 +352,9 @@ public static LoggingSystem get(ClassLoader classLoader) { - 添加配置文件 -![image-20200323161442058](../../../images/SpringBoot/image-20200323161442058.png) +![image-20200323161442058](../../images/SpringBoot/image-20200323161442058.png) -![image-20200323161522570](../../../images/SpringBoot/image-20200323161522570.png) +![image-20200323161522570](../../images/SpringBoot/image-20200323161522570.png) - 此时配置文件地址出现了 diff --git a/docs/SpringBoot/SpringBoot-application-load.md b/docs/SpringBoot/SpringBoot-application-load.md index bdfed37..85fe34e 100644 --- a/docs/SpringBoot/SpringBoot-application-load.md +++ b/docs/SpringBoot/SpringBoot-application-load.md @@ -9,17 +9,17 @@ 2. 全局搜索 yml - ![image-20200319083048849](../../../images/SpringBoot/image-20200319083048849.png) + ![image-20200319083048849](../../images/SpringBoot/image-20200319083048849.png) 3. 换成`properties`搜索 - ![image-20200319083140225](../../../images/SpringBoot/image-20200319083140225.png) + ![image-20200319083140225](../../images/SpringBoot/image-20200319083140225.png) 4. 我们以`yml`为例打上断点开始源码追踪 看到调用堆栈 -![image-20200319083345067](../../../images/SpringBoot/image-20200319083345067.png) +![image-20200319083345067](../../images/SpringBoot/image-20200319083345067.png) - 一步一步回上去看如何调用具体方法的 @@ -29,9 +29,9 @@ ### 调用过程 -![image-20200319082131146](../../../images/SpringBoot/image-20200319082131146.png) +![image-20200319082131146](../../images/SpringBoot/image-20200319082131146.png) -![image-20200319082544653](../../../images/SpringBoot/image-20200319082544653.png) +![image-20200319082544653](../../images/SpringBoot/image-20200319082544653.png) `org.springframework.boot.context.config.ConfigFileApplicationListener#addPropertySources` @@ -68,13 +68,13 @@ protected void addPropertySources(ConfigurableEnvironment environment, ResourceL - 搜索目标: `org.springframework.boot.env.PropertySourceLoader` - ![image-20200319084141748](../../../images/SpringBoot/image-20200319084141748.png) + ![image-20200319084141748](../../images/SpringBoot/image-20200319084141748.png) -![image-20200319084151997](../../../images/SpringBoot/image-20200319084151997.png) +![image-20200319084151997](../../images/SpringBoot/image-20200319084151997.png) 观察发现里面有一个`YamlPropertySourceLoader`和我们之前找 yml 字符串的时候找到的类是一样的。说明搜索方式没有什么问题。 -![image-20200319084357652](../../../images/SpringBoot/image-20200319084357652.png) +![image-20200319084357652](../../images/SpringBoot/image-20200319084357652.png) 初始化完成,后续进行解析了 @@ -110,7 +110,7 @@ protected void addPropertySources(ConfigurableEnvironment environment, ResourceL ### initializeProfiles - 初始化`private Deque profiles;` 属性 -- ![image-20200319084902957](../../../images/SpringBoot/image-20200319084902957.png) +- ![image-20200319084902957](../../images/SpringBoot/image-20200319084902957.png) ### load @@ -135,7 +135,7 @@ private void load(Profile profile, DocumentFilterFactory filterFactory, Document - 资源路径可能性 -![image-20200319085446640](../../../images/SpringBoot/image-20200319085446640.png) +![image-20200319085446640](../../images/SpringBoot/image-20200319085446640.png) 该方法采用循环每个路径下面都去尝试一遍 @@ -190,7 +190,7 @@ private void load(Profile profile, DocumentFilterFactory filterFactory, Document ``` -![image-20200319090446231](../../../images/SpringBoot/image-20200319090446231.png) +![image-20200319090446231](../../images/SpringBoot/image-20200319090446231.png) - `PropertiesPropertySourceLoader`解析同理不在次展开描述了 diff --git a/docs/SpringBoot/SpringBoot-自动装配.md b/docs/SpringBoot/SpringBoot-自动装配.md index a122894..54fd80b 100644 --- a/docs/SpringBoot/SpringBoot-自动装配.md +++ b/docs/SpringBoot/SpringBoot-自动装配.md @@ -53,7 +53,7 @@ public @interface EnableAutoConfiguration { - 类图 -![image-20200320150642022](../../../images/SpringBoot/image-20200320150642022.png) +![image-20200320150642022](../../images/SpringBoot/image-20200320150642022.png) ## getAutoConfigurationMetadata() @@ -107,7 +107,7 @@ public @interface EnableAutoConfiguration { ``` - ![image-20200320160423991](../../../images/SpringBoot/image-20200320160423991.png) + ![image-20200320160423991](../../images/SpringBoot/image-20200320160423991.png) - `protected static final String PATH = "META-INF/spring-autoconfigure-metadata.properties";` @@ -131,11 +131,11 @@ public @interface EnableAutoConfiguration { org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration,\ ``` -![image-20200320162835665](../../../images/SpringBoot/image-20200320162835665.png) +![image-20200320162835665](../../images/SpringBoot/image-20200320162835665.png) 同样找一下 redis -![image-20200320163001728](../../../images/SpringBoot/image-20200320163001728.png) +![image-20200320163001728](../../images/SpringBoot/image-20200320163001728.png) - 仔细看`org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration`类 @@ -213,13 +213,13 @@ public class RedisProperties { - `org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.AutoConfigurationGroup#process` - ![image-20200320163806852](../../../images/SpringBoot/image-20200320163806852.png) + ![image-20200320163806852](../../images/SpringBoot/image-20200320163806852.png) 再此之前我们看过了`getAutoConfigurationMetadata()`的相关操作 关注 `AnnotationMetadata annotationMetadata` 存储了一些什么 -![image-20200320164145286](../../../images/SpringBoot/image-20200320164145286.png) +![image-20200320164145286](../../images/SpringBoot/image-20200320164145286.png) 这里简单理解 @@ -271,7 +271,7 @@ public class RedisProperties { ``` -![image-20200320171138431](../../../images/SpringBoot/image-20200320171138431.png) +![image-20200320171138431](../../images/SpringBoot/image-20200320171138431.png) ### getCandidateConfigurations @@ -289,7 +289,7 @@ public class RedisProperties { ``` -![image-20200320171734270](../../../images/SpringBoot/image-20200320171734270.png) +![image-20200320171734270](../../images/SpringBoot/image-20200320171734270.png) - 第一个是我自己写的一个测试用 @@ -341,7 +341,7 @@ public class RedisProperties { ``` -![image-20200323080611527](../../../images/SpringBoot/image-20200323080611527.png) +![image-20200323080611527](../../images/SpringBoot/image-20200323080611527.png) - 修改启动类 @@ -350,7 +350,7 @@ public class RedisProperties { ``` - ![image-20200323081009823](../../../images/SpringBoot/image-20200323081009823.png) + ![image-20200323081009823](../../images/SpringBoot/image-20200323081009823.png) ### checkExcludedClasses @@ -418,7 +418,7 @@ public class RedisProperties { - `getAutoConfigurationImportFilters()` 从`spring.factories` 获取 `AutoConfigurationImportFilter`的接口 -![image-20200323081903145](../../../images/SpringBoot/image-20200323081903145.png) +![image-20200323081903145](../../images/SpringBoot/image-20200323081903145.png) - 循环内执行`Aware`系列接口 @@ -426,7 +426,7 @@ public class RedisProperties { - `filter.match(candidates, autoConfigurationMetadata)` 比较判断哪些是需要自动注入的类 -![image-20200323082553595](../../../images/SpringBoot/image-20200323082553595.png) +![image-20200323082553595](../../images/SpringBoot/image-20200323082553595.png) ### fireAutoConfigurationImportEvents @@ -448,11 +448,11 @@ public class RedisProperties { ``` -![image-20200323083149737](../../../images/SpringBoot/image-20200323083149737.png) +![image-20200323083149737](../../images/SpringBoot/image-20200323083149737.png) - `AutoConfigurationImportEvent event = new AutoConfigurationImportEvent(this, configurations, exclusions);` -![image-20200323083247061](../../../images/SpringBoot/image-20200323083247061.png) +![image-20200323083247061](../../images/SpringBoot/image-20200323083247061.png) - `org.springframework.boot.autoconfigure.AutoConfigurationImportListener#onAutoConfigurationImportEvent` 在执行自动配置时触发 , 实现类只有 **`ConditionEvaluationReportAutoConfigurationImportListener`** @@ -470,7 +470,7 @@ public class RedisProperties { ``` -![image-20200323083656670](../../../images/SpringBoot/image-20200323083656670.png) +![image-20200323083656670](../../images/SpringBoot/image-20200323083656670.png) - 初始化完 @@ -478,7 +478,7 @@ public class RedisProperties { - `org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.AutoConfigurationGroup#process` -![image-20200323084922159](../../../images/SpringBoot/image-20200323084922159.png) +![image-20200323084922159](../../images/SpringBoot/image-20200323084922159.png) - 后续的一些行为相对简单,直接放个源码了.