【SpringBoot】MyBatis-plus 报错 Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required

🎄欢迎来到@边境矢梦°的csdn博文🎄
🎄本文主要梳理本文针对 MyBatis-plus,对于 MyBatis 报相同的错误,可以看这个大佬的文章:SpringBoot3整合MyBatis报错:Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required 🎄
🌈我是边境矢梦°,一个正在为秋招和算法竞赛做准备的学生🌈
🎆喜欢的朋友可以关注一下🫰🫰🫰,下次更新不迷路🎆

针对报错如下:

Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

方法1: 就用SpringBoot 3

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

	<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.1</version>
        <relativePath/>
    </parent>

<dependency> 部分:

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.3</version>
        </dependency>

方法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 版本之间有较大变化,按需使用即可)。
<parent> 部分:

	<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.8</version>
        <relativePath/> 
    </parent>

<dependency> 部分:

        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.3</version>
        </dependency>

版权声明:本文为博主作者:边境矢梦°原创文章,版权归属原作者,如果侵权,请联系我们删除!

原文链接:https://blog.csdn.net/dandelionl_/article/details/134892975

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2024年1月3日
下一篇 2024年1月3日

相关推荐