- 读取applicationContext.xml
- 导入spring-dao.xml
- 读取db.properties
- 配置dataSource
- sqlSessionFactory
- 注入dataSource
- 绑定mybatis配置文件
- 绑定*Mapper.xml
- sqlSessionTemplate
- 构造器注入sqlSessionFactory
- 注册bean
- accountMapper
- AccountMapperImpl
- 注入sqlSessionTemplate
- accountMapper2
- AccountMapperImpl2
- 注入sqlSessionFactory
- accountMapper
- 导入spring-dao.xml
- getBean
- 获取accountMapper这个bean
- 调用accountMapper的selectAllAccount方法
- AccountMapperImpl实现了该方法
- 需要注入sqlSessionTemplate,applicationContext.xml配置好了
- sqlSessionTemplate获取mapper(AccountMapper.class)
- 该mapper和AccountMapper.xml绑定了
- 执行SQL
- 输出返回结果
Spring ~spring整合mybatis
猜你喜欢
转载自blog.csdn.net/m0_47585722/article/details/120486249
今日推荐
周排行