SpringBoot自动配置源码解析

一、自动配置原理入门

1.1 @SpringBootConfiguration

@Configuration:代表当前是一个配置类 

@ComponentScan:指定扫描哪些包

@EnableAutoConfiguration:

@AutoConfigurationPackage
@Import({AutoConfigurationImportSelector.class})
public @interface EnableAutoConfiguration {
    // ...
}

@AutoConfigurationPackage:自动配置包

@Import({Registrar.class}) // 给容器中导入组件
public @interface AutoConfigurationPackage {
    // 利用register给容器中导入一系列组件
}

详细讲义:https://www.yuque.com/atguigu/springboot/qb7hy2

雷丰阳2021版SpringBoot2零基础入门springboot全套完整版(spring boot2)

猜你喜欢

转载自blog.csdn.net/qq_30398499/article/details/113723028