自定义xml spring bean
一. xml中bean解析过程
扫描META-INF下面的
spring.schemas bean定义对应的xsd位置,在IDEA中可以辅助校验)
spring.handlers xmlns对应的bean具体解析器, 一般会继承NamespaceHandlerSupport,
NSHandler下面是具体解析过程, 最终返回的结果是spring中的BeanDefinition
参见<dubbo:config> <hsf:provider> <mvc:annotation-driven>的解析过程
二. 注解形式的自定义bean
BeanDefinitionRegistryPostProcessor mybatis中的bean注解扫描过程, ===> mapper接口为何可以使用Autowire自动注入 扫描包下的所有类都会创建成对应的MapperFactoryBean对象,同时继承了FactoryBean, 在spring容器getBean时调用FactoryBean的getObject方法,生成mapper的proxy对象
@Import(MapperScannerRegistrar.class)
public @interface MapperScan
如果使用了MapperScan,就会使用MapperScannerRegistrar.class扫描mapperScan定义的包名, 在里面创建mapper对应的MapperFactoryBean
@Import({ AutoConfiguredMapperScannerRegistrar.class })
@ConditionalOnMissingBean(MapperFactoryBean.class)
public static class MapperScannerRegistrarNotFoundConfiguration
如果没有使用MapperScan, 使用的是org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration.MapperScannerRegistrarNotFoundConfiguration上面import引入的AutoConfiguredMapperScannerRegistrar来扫描基础包名
注意这个注解@ConditionalOnMissingBean
resources下面的mapper.xml是什么时候加载进去的?
MybatisAutoConfiguration里面sessionFactory初始化时 factory.setMapperLocations(this.properties.resolveMapperLocations());
最新文章
- ELK 集中日志分析 windows部署实战
- socket.io,远程控制你的幻灯片
- 让/etc/profile文件修改后立即生效(转)
- 兄弟连王牌PHP课程送三重豪礼啦!
- solr安装
- J2EE之普通类载入web资源文件的方法
- String ,StringBuffer,StringBuilder精髓比較
- mysql学习笔记--数据库预处理
- Django Admin后台管理用户密码修改
- Flask中无法在其他函数中查询Sqlachemy的解决办法
- git常用命令(转载自用)
- route命令详解
- C语言编码转换gb2312 to utf8,utf8 to gb2312 代码,GCC编译,支持Windows、Linux
- C/C++中如何获取数组的长度?
- 上云、微服务化和DevOps,少走弯路的办法
- 2_C语言中的数据类型 (六)浮点数
- 【Leetcode】【Medium】Construct Binary Tree from Preorder and Inorder Traversal
- dbcp基本配置和重连配置
- UESTC 30.最短路-最短路(Floyd or Spfa(链式前向星存图))
- IIPP迷你项目(二)";Guess the Number!";