1.回顾spring整合mybatis
1.引入依赖
spring相关
mysql相关 mysql驱动 druid数据源
mybatis相关的 mybatis核心jar mybatis和spring框架整合
2.书写配置
a.开启注解扫描 @SpringBootApplication @ComponentScan 省略
b.创建数据源
1.指定数据源类型
2.指定数据库驱动
3.指定url
4.指定username
5.指定password
c. 创建SqlSessionFactory
1.指定mapper配置文件位置
2.指定实体所在包位置 起别名
d.创建DAO
1.指定DAO接口所在包
e.创建事务管理器 开启注解式事务生效 省略
3.测试
1).建表
2).开发实体类
3).开发DAO接口
4).开发Mapper配置文件
5).开发Service接口
6).开发ServiceImpl实现类
7).测试ServiceImpl
2.springboot整合mybatis
1.引入依赖
spring-boot-stater-web
mysql相关 mysql驱动 druid数据源
mybatis相关的 (mybatis-spring-boot-stater) 依赖 (mybatis mybatis-spring)
2.书写配置
a.开启注解扫描 @SpringBootApplication @ComponentScan 省略
b.创建数据源
1.指定数据源类型
2.指定数据源驱动
3.指定url
4.指定username
5.指定password
c.创建SQLSessionFactory
1.指定mapper配置文件位置
2.指定实体所在包位置 起别名
d.创建DAO
1.指定DAO接口所在包
e.创建事务管理器 开启注解式事务生效 省略