MyBatis 与 Spring Boot版本匹配问题


✅ 问题定位:

使用的是:

  • Spring Boot 3.4.8
  • MyBatis Spring Boot Starter 2.2.2

但:

mybatis-spring-boot-starter:2.2.2 是为 Spring Boot 2.x 设计的,不支持 Spring Boot 3.x


✅ 正确做法:

升级 MyBatis 到 Spring Boot 3.x 兼容版本,例如:

xml 复制代码
<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>3.0.4</version> <!-- ✅ 支持 Spring Boot 3.x -->
</dependency>

✅ 总结一句话:

Spring Boot 3.x 必须使用 MyBatis 3.x 版本,否则会出现 Bean 注入失败、Mapper 无法识别等问题。


✅ 建议:

修改 pom.xml 中的版本后,执行:

bash 复制代码
mvn clean install

然后重新运行项目或测试类。

相关推荐
蒸蒸yyyyzwd2 小时前
cpp对象模型学习笔记1.1-2.8
java·笔记·学习
qq_297574673 小时前
【实战教程】SpringBoot 集成阿里云短信服务实现验证码发送
spring boot·后端·阿里云
程序员徐师兄3 小时前
Windows JDK11 下载安装教程,适合新手
java·windows·jdk11 下载安装·jdk11 下载教程
RANCE_atttackkk3 小时前
[Java]实现使用邮箱找回密码的功能
java·开发语言·前端·spring boot·intellij-idea·idea
五岳4 小时前
DTS按业务场景批量迁移阿里云MySQL表实战(下):迁移管理平台设计与实现
java·应用·dts
韩立学长4 小时前
【开题答辩实录分享】以《智能大学宿舍管理系统的设计与实现》为例进行选题答辩实录分享
数据库·spring boot·后端
zhougl9964 小时前
Java 所有关键字及规范分类
java·开发语言
Python 老手4 小时前
Python while 循环 极简核心讲解
java·python·算法
java1234_小锋5 小时前
Java高频面试题:MyISAM索引与InnoDB索引的区别?
java·开发语言
Mr_Xuhhh5 小时前
MySQL函数详解:日期、字符串、数学及其他常用函数
java·数据库·sql