|
|
|
@ -53,7 +53,7 @@ public @interface EnableAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
- 类图
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
## getAutoConfigurationMetadata()
|
|
|
|
|
|
|
|
|
@ -107,7 +107,7 @@ public @interface EnableAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
- `protected static final String PATH = "META-INF/spring-autoconfigure-metadata.properties";`
|
|
|
|
|
|
|
|
|
@ -131,11 +131,11 @@ public @interface EnableAutoConfiguration {
|
|
|
|
|
org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration,\
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
同样找一下 redis
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
- 仔细看`org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration`类
|
|
|
|
|
|
|
|
|
@ -213,13 +213,13 @@ public class RedisProperties {
|
|
|
|
|
|
|
|
|
|
- `org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.AutoConfigurationGroup#process`
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
再此之前我们看过了`getAutoConfigurationMetadata()`的相关操作
|
|
|
|
|
|
|
|
|
|
关注 `AnnotationMetadata annotationMetadata` 存储了一些什么
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
这里简单理解
|
|
|
|
|
|
|
|
|
@ -271,7 +271,7 @@ public class RedisProperties {
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
### getCandidateConfigurations
|
|
|
|
|
|
|
|
|
@ -289,7 +289,7 @@ public class RedisProperties {
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
- 第一个是我自己写的一个测试用
|
|
|
|
|
|
|
|
|
@ -341,7 +341,7 @@ public class RedisProperties {
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
- 修改启动类
|
|
|
|
|
|
|
|
|
@ -350,7 +350,7 @@ public class RedisProperties {
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
### checkExcludedClasses
|
|
|
|
|
|
|
|
|
@ -418,7 +418,7 @@ public class RedisProperties {
|
|
|
|
|
|
|
|
|
|
- `getAutoConfigurationImportFilters()` 从`spring.factories` 获取 `AutoConfigurationImportFilter`的接口
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
- 循环内执行`Aware`系列接口
|
|
|
|
|
|
|
|
|
@ -426,7 +426,7 @@ public class RedisProperties {
|
|
|
|
|
|
|
|
|
|
- `filter.match(candidates, autoConfigurationMetadata)` 比较判断哪些是需要自动注入的类
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
### fireAutoConfigurationImportEvents
|
|
|
|
|
|
|
|
|
@ -448,11 +448,11 @@ public class RedisProperties {
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
- `AutoConfigurationImportEvent event = new AutoConfigurationImportEvent(this, configurations, exclusions);`
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
- `org.springframework.boot.autoconfigure.AutoConfigurationImportListener#onAutoConfigurationImportEvent` 在执行自动配置时触发 , 实现类只有 **`ConditionEvaluationReportAutoConfigurationImportListener`**
|
|
|
|
|
|
|
|
|
@ -470,7 +470,7 @@ public class RedisProperties {
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
- 初始化完
|
|
|
|
|
|
|
|
|
@ -478,7 +478,7 @@ public class RedisProperties {
|
|
|
|
|
|
|
|
|
|
- `org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.AutoConfigurationGroup#process`
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
- 后续的一些行为相对简单,直接放个源码了.
|
|
|
|
|
|
|
|
|
|