“Spring Boot 自动包规则原理”的版本间的差异
跳到导航
跳到搜索
Jihongchang(讨论 | 贡献) |
Jihongchang(讨论 | 贡献) |
||
第25行: | 第25行: | ||
public @interface EnableAutoConfiguration { | public @interface EnableAutoConfiguration { | ||
…… | …… | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==== @AutoConfigurationPackage ==== | ||
+ | <syntaxhighlight lang="java"> | ||
+ | @Retention(RetentionPolicy.RUNTIME) | ||
+ | @Documented | ||
+ | @Inherited | ||
+ | @Import(AutoConfigurationPackages.Registrar.class) | ||
+ | public @interface AutoConfigurationPackage { | ||
</syntaxhighlight> | </syntaxhighlight> |
2023年2月15日 (三) 07:10的版本
https://www.bilibili.com/video/BV19K4y1L7MT/?p=13
引导加载自动配置类
查看 @SpringBootApplication 注解源代码
……
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface SpringBootApplication {
查看 @SpringBootConfiguration
@Configuration
public @interface SpringBootConfiguration {
@Configuration 代表当前是一个配置类
@ComponentScan 指定扫描哪些类包,Spring 注解;
@EnableAutoConfiguration
……
@AutoConfigurationPackage
@Import(AutoConfigurationImportSelector.class)
public @interface EnableAutoConfiguration {
……
@AutoConfigurationPackage
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Import(AutoConfigurationPackages.Registrar.class)
public @interface AutoConfigurationPackage {