配置介绍

122 阅读1分钟

内部类处理

image.png

PropertySource处理

用法:@PropertySource({"demo.properties"})

遍历指定路径,替换占位符,加载资源

将资源添加到environment中

ComponentScan处理

@ComponentScan(basePackages={"pkgA","pkgB"},basePackageClasses={A.class,B.class})

没设置扫描路径的话使用配置类所在类的路径

过滤顺序:excludeFilters->includeFilters->false

Import处理

ImportSelector.class & DeferredImportSelector.class

处理以上两个接口实现selectImports返回的类名数组

DeferredImportSelector接口调用优先级会低于其他接口

处理ImportBeanDefinitionRegistrar实现中注册的bean

处理@Import(A.class)

ImportResource处理

@ImportResource("xyz.xml")

将注解属性值放入importedResources中

后续loadBeanDefinitionsForConfigurationClass中加载定义的bean

BeanMethod处理

image.png

构造BeanMethod对象放入配置类属性中后续处理