Spring源码分析【4】-Spring扫描basePackages注解
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. ComponentScanAnnotationParser.parse
org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.resolveBasePackage
org.springframework.util.ClassUtils.convertClassNameToResourcePath
getResources
getResources
findPathMatchingResources
determineRootDir
回到findPathMatchingResources
findPathMatchingResources的result
一直退回到findCandidateComponents
MetadataReader metadataReader = this.metadataReaderFactory.getMetadataReader(resource);
MetadataReader
if (isCandidateComponent(metadataReader))
ScannedGenericBeanDefinition
回到findCandidateComponents
return candidates;
返回doScan
checkCandidate
回doScan
BeanDefinitionHolder
beanDefinitions.add(definitionHolder);
registerBeanDefinition
registerBeanDefinition
oldBeanDefinition = this.beanDefinitionMap.get(beanName);
if (hasBeanCreationStarted())
this.beanDefinitionMap.put(beanName, beanDefinition);
updatedDefinitions
doScan return beanDefinitions;
org.springframework.context.annotation.ComponentScanAnnotationParser.parse
org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass
parse
org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass
this.configurationClasses.put(configClass, configClass);
回到doProcessConfigurationClass
for (SourceClass ifc : sourceClass.getInterfaces()) {
doProcessConfigurationClass
// No superclass -> processing is complete
return null;
processConfigurationClass
org.springframework.context.annotation.ConfigurationClassParser.parse
parse
org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions
alreadyParsed.addAll(configClasses);
alreadyParsedClasses
invokeBeanDefinitionRegistryPostProcessors
org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors
// Now, invoke the postProcessBeanFactory callback of all processors handled so far.invokeBeanFactoryPostProcessors(registryPostProcessors, beanFactory);invokeBeanFactoryPostProcessors(regularPostProcessors, beanFactory);
postProcessorNames
refresh
Spring源码分析【4】-Spring扫描basePackages注解相关推荐
- spring源码分析第六天------spring经典面试问题
spring源码分析第六天------spring经典面试问题 1.Spring5 新特性及应用举例 2.Spring 经典的面试问题 a.什么是 Spring 框架?Spring 框架有哪些主要模块 ...
- Spring源码分析3 — spring XML配置文件的解析流程
1 介绍 创建并初始化spring容器中,关键一步就是读取并解析spring XML配置文件.这个过程比较复杂,本文将详细分析整个流程.先看涉及到的关键类. XmlWebApplicationCont ...
- Spring源码分析4 — spring bean创建和初始化
1 介绍 创建并初始化spring容器中,refresh()方法中解析xml配置文件,注册容器后处理器,bean后处理器,初始化MessageSource,ApplicationEventMultic ...
- Spring源码分析【8】-MyBatis注解方法不能重载
代码如下: 这是不可以的,会报错: 2016-08-18 11:36:00,267 [main] ERROR [org.mybatis.spring.mapper.MapperFactoryBean] ...
- spring源码分析之spring注解@Aspect是如何工作的?
AOP(Aspect Orient Programming),面向切面编程,是面向对象编程OOP的一种补充.面向对象编程是从静态角度考虑程序的结构,面向切面编程是从动态的角度考虑程序运行过程. AOP ...
- spring源码分析之spring jmx
JMX架构定义: https://docs.oracle.com/javase/8/docs/technotes/guides/jmx/overview/architecture.html Archi ...
- Spring源码分析(三)
Spring源码分析 第三章 手写Ioc和Aop 文章目录 Spring源码分析 前言 一.模拟业务场景 (一) 功能介绍 (二) 关键功能代码 (三) 问题分析 二.使用ioc和aop重构 (一) ...
- Spring 源码分析衍生篇十 :Last-Modified 缓存机制
文章目录 一.前言 二.Last-Modify 三.实现方案 1. 实现 org.springframework.web.servlet.mvc.LastModified接口 1.1. 简单演示 1. ...
- Spring源码分析八:Mybatis ORM映射框架原理
文章目录 (一)Mybatis单独操作数据库程序 1.1.数据库表 1.2.建立PO 1.3.建立mapper接口映射 1.4.建立Mybatis配置文件 1.5.建立mapper映射文件 1.6.测 ...
- Spring 源码分析衍生篇十三 :事务扩展机制 TransactionSynchronization
文章目录 一.前言 二.TransactionSynchronization 1. TransactionSynchronization 1.1 TransactionSynchronization ...
最新文章
- JQuery UI – droppable 中文文档
- Powershell 自定义输出列,两个例子
- Ubuntu中搭建Hadoop2.5.2完全分布式系统(一)
- linux高级运维笔试简答题及答案,企业linux初级和高级运维面试常问题目问答总结技巧讲解(2020年录制)...
- jQuery 的常用选择器,筛选器
- 读《启示录》有感-----1
- vue 微信支付的坑_vue_模式下h5微信支付
- leetcode98 验证二叉搜索树
- Endnote自定义参考文献格式锦集
- INET Sockets Tour: ioctl()
- python数据结构之列表(list)——超详细
- python必背100源代码-python 100例 (持续更新)
- 本地搭建Redis集群 windows(图文详解)
- 爬取百度贴吧发帖信息并保存到scv文件中
- 增值税相关软件基本常识
- go——垃圾回收机制(GC)
- [转贴][教学] 教你如何打飞机 ^_^
- 学而思python分几个level_学而思新概念英语课程体系表
- spark的数三角形算法_Graphx图算法【1】三角形TriangleCount
- 电脑游戏怎么转移新电脑,换新电脑如何迁移游戏
热门文章
- html文件显示不了box,Workbox.js registerNavigationRoute找不到/加载html文件
- 力扣(LeetCode)刷题,简单题(第2期)
- 深度学习(3)基础3 -- 前向传播与反向传播
- linux查看流量开源,Linux流量监控工具 - iftop
- 心跳实现_真强啊!建议每一位Java程序员都读读Dubbo心跳设计的源码...
- Windows下修改jupyter默认工作路径教程
- 用v-for循环动态定位坐标显示元素,并遍历元素的left和top坐标位置(只需要用到元素的宽高、索引、每行显示数量)
- Blender从头到尾创建一辆宝马轿车视频教程
- hibernate 和 mybatis 的区别
- ASP.NET Aries 高级开发教程:Excel导入配置之规则说明(下)