小工具知识网

当前位置: 首页 > 行业知识 > 【SpringBoot】MyBatis-plus 报错 sqlSessionFactory sqlSessionTemplate 最新解决办法

行业知识

【SpringBoot】MyBatis-plus 报错 sqlSessionFactory sqlSessionTemplate 最新解决办法

2026-12-06 19:38:17 来源:互联网转载

本文针对 MyBatis-plus,对于 MyBatis 报相同的错误,可以看这个大佬的文章:SpringBoot3整合MyBatis报错:Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required

()

针对报错如下:

Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

其他的帖子大多都停留在 SpringBoot 2版本时代,MyBatis 在2022年11月才对 SpringBoot 3 提供支持,MyBatis-plus 在 12月28号才同步支持,如果其他文章不能解决该报错,那么新的途径如下。

()

方法1: 就用SpringBoot 3(反骨)

如果 pom.xml 中spring-boot-starter-parent 的版本 需要 使用 3.0.0 或以上,则 mybatis-plus-boot-starter 的版本必须为 3.5.3 或以上。对应如下两部分代码:

部分:

        org.springframework.boot        spring-boot-starter-parent        3.0.1            

部分:

                    com.baomidou            mybatis-plus-boot-starter            3.5.3        

方法2:不需要使用SpringBoot 3

如果 pom.xml 中spring-boot-starter-parent 的版本 不需要 使用 3.0.0 或以上,则可以将其版本改为 2.7.8 即 SpringBoot 2 版本, mybatis-plus-boot-starter 的版本无需使用最新的 3.5.3(mybatis-plus 在 3.4 和 3.5 版本之间有较大变化,按需使用即可)。

部分:

        org.springframework.boot        spring-boot-starter-parent        2.7.8             

部分:

                    com.baomidou            mybatis-plus-boot-starter            3.5.3         

上一篇:服务器带宽怎么计算?

下一篇:服务器怎么搭建桌面?