首页 > 基础资料 博客日记

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

2024-01-09 21:32:48基础资料围观279

文章【SpringBoot】MyBatis-plus 报错 Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required分享给大家,欢迎收藏Java资料网,专注分享技术知识

🎄欢迎来到@边境矢梦°的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
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!

标签:

相关文章

本站推荐

标签云