org.springframework.beans.factory.support.DefaultListableBeanFactory
重要数据结构
/** Map of bean definition objects, keyed by bean name */
private final Map<String, BeanDefinition> beanDefinitionMap = new ConcurrentHashMap<String, BeanDefinition>(256);
RootConfig 代码
@Configuration
@Import(MybatisConfig.class)
@ComponentScan(basePackages = {"com.xxx.*"},
excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = EnableWebMvc.class)})
public class RootConfig {
}
org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.resolveBasePackage
Spring源码解析:ClassPathBeanDefinitionScanner与basePackages扫描

本文深入探讨了Spring框架中`DefaultListableBeanFactory`如何通过`ClassPathBeanDefinitionScanner`和`ClassPathScanningCandidateComponentProvider`进行基于`basePackages`的组件扫描。从`doScan`方法开始,跟踪到`findCandidateComponents`,了解扫描过程,包括资源路径转换、候选组件筛选以及BeanDefinition的注册。文章详细分析了源码流程,帮助读者理解Spring的初始化配置过程。
最低0.47元/天 解锁文章
1391

被折叠的 条评论
为什么被折叠?



