SpringBoot的数据访问
SpringBoot简化了项目开发过程 (很多的自动配置)
SpringBoot 关系型 还是非关系型 都有很好的支持
SpringBoot数据访问概述
SpringBoot 采用SpringData方式整合 添加大量的自动配置
各种数据访问模板 xxxxRemplate 一些统一接口 Repoditory接口
SpringBoot 中常见的数据库依赖启动器
SpringBoot整合MyBatis
- 基础环境的搭建
- 数据准备 创建数据库 创建表 插入数据
使用mySql 创建springbootdata数据库 创建两个表t_article t_comment
并且插入数据
使用配置文件方式整合MyBatis
整合步骤:
-
创建Mapper接口文件
-
创建xml映射文件:编写对应的sql
-
在全局配置文件中配置xml映射和实体别名
-
编写测试方法