当前位置: 首页> 财经> 金融 > SpringBoot整合MyBatis-Plus

SpringBoot整合MyBatis-Plus

时间:2025/7/9 3:23:47来源:https://blog.csdn.net/weixin_43866613/article/details/139765241 浏览次数:1次

黑马程序员Spring Boot2

文章目录

  • 1、步骤
    • 1.1 手动添加坐标
    • 1.2 配置
    • 1.3 定义数据层接口与映射配置,继承BaseMapper
    • 1.4 测试

1、步骤

1.1 手动添加坐标

  • 手动添加SpringBoot整合MyBatis-Plus 的坐标,可以通过mvnrepository获取
  1. 创建新的模块,勾选 MySQL Driver
    在这里插入图片描述
    在这里插入图片描述
  2. 访问 https://mvnrepository.com/ 搜索 mybatis plus ,点击第一个,自行选择一个版本,复制其坐标,粘贴到 pom.xml 中,刷新Maven之后爆红消失
    在这里插入图片描述
    在这里插入图片描述
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.4.3</version></dependency>

注意事项:由于SpringBoot中未收录MyBatis-Plus 的坐标版本,需要指定对应的Version

1.2 配置

  • 在application.yml 中配置数据库连接相关信息
    在这里插入图片描述
# 配置相关信息
spring:datasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/mytliasusername: rootpassword: 123456

1.3 定义数据层接口与映射配置,继承BaseMapper

在这里插入图片描述

1.4 测试

在这里插入图片描述

关键字:SpringBoot整合MyBatis-Plus

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: