Skip to content

Commit 006f955

Browse files
committed
Update Java Notes
1 parent c03d5e0 commit 006f955

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

SSM.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3946,9 +3946,16 @@ Mybatis 核心配置文件消失
39463946

39473947
- 类型别名交由 spring 处理
39483948

3949-
业务发起使用spring上下文对象获取对应的bean
3949+
DAO 接口不需要创建实现类,MyBatis-Spring 提供了一个动态代理的实现 **MapperFactoryBean**,这个类可以让直接注入数据映射器接口到 service 层 bean 中,底层将会动态代理创建类
39503950

3951-
**原理**:DAO 接口不需要创建实现类,MyBatis-Spring 提供了一个动态代理的实现 **MapperFactoryBean**,这个类可以让直接注入数据映射器接口到 service 层 bean 中,底层将会动态代理创建类
3951+
整合原理:利用 Spring 框架的 SPI 机制,在 META-INF 目录的 spring.handlers 中给 Spring 容器中导入 NamespaceHandler 类
3952+
3953+
* NamespaceHandler 的 init 方法注册 bean 信息的解析器 MapperScannerBeanDefinitionParser
3954+
* 解析器在 Spring 容器创建过程中去解析 mapperScanner 标签,解析出的属性填充到 MapperScannerConfigurer 中
3955+
3956+
* MapperScannerConfigurer 实现了 BeanDefinitionRegistryPostProcessor 接口,重写 postProcessBeanDefinitionRegistry() 方法,可以扫描到 MyBatis 的 Mapper
3957+
3958+
整合代码:
39523959

39533960
* pom.xml,导入坐标
39543961

@@ -4911,7 +4918,7 @@ FactoryBean与 BeanFactory 区别:
49114918
}
49124919
```
49134920

4914-
* MapperScannerConfigurer 实现了 BeanDefinitionRegistryPostProcessor 接口,重写 postProcessBeanDefinitionRegistry() 方法,可以扫描到 MyBatis 的 Mapper
4921+
49154922

49164923

49174924

0 commit comments

Comments
 (0)