springboot2.x整合mybatis和mysql

2024-10-22 23:09:42

1、创建springboot项目,添加mybatis和mysql依赖。web依赖用于展示数据

springboot2.x整合mybatis和mysql

2、在applicatin.properties中配置数据源。连接本地的mysql数据库。

springboot2.x整合mybatis和mysql

4、在mybatis中创建表。这里用mybatis自带的一张表

springboot2.x整合mybatis和mysqlspringboot2.x整合mybatis和mysqlspringboot2.x整合mybatis和mysql

6、创建mapper.xml文件

springboot2.x整合mybatis和mysql

7、编辑启动器类,增加mapper映射

springboot2.x整合mybatis和mysql
猜你喜欢