网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

springboot2.x整合mybatis和mysql

时间:2024-10-22 23:09:42

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

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

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

springboot2.x整合mybatis和mysql

3、在application.properties中设置mybatis的映射文件路径

springboot2.x整合mybatis和mysql

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

springboot2.x整合mybatis和mysql

5、创建实体类、控制器、业务逻辑等代码

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

6、创建mapper.xml文件

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

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

springboot2.x整合mybatis和mysql

8、启动项目和postman访问项目即可

springboot2.x整合mybatis和mysql
© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com