当前位置: 首页 > news >正文

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

本文针对 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 或以上。对应如下两部分代码:
<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>
http://www.lryc.cn/news/10508.html

相关文章:

  • jsp诊疗预约系统Myeclipse开发mysql数据库web结构java编程计算机网页项目
  • 详解 APISIX Lua 动态调试插件 inspect
  • #科研筑基# python初学自用笔记 第五篇 函数
  • 设计模式之策略模式
  • dbdeployer 使用札记
  • MATLAB算法实战应用案例精讲-【图像处理】数字图像模糊化(附Java、python和matlab代码实现)
  • 搭建Hexo博客-第1章-Git和GitHub以及Coding的简单用法
  • 【C++修行之路】C/C++内存管理
  • spring cloud alibaba Sentinel(四)
  • Redis第三讲
  • JAVA线程池的使用
  • 力扣56.合并区间
  • 代码随想录二刷Day03链表: 24.两两交换链表中的节点,19.删除链表的倒数第N个节点,面试题 02.07. 链表相交,142.环形链表||
  • 我应该在我的博客上写什么? 介绍如何撰写初学者容易担心的文章
  • 嵌入式C语言设计模式 --- 外观模式
  • 若依ruoyi——手把手教你制作自己的管理系统【三、代码生成】
  • SCI论文写作神器集合 —— 超级实用
  • MAC 系统安装多版本 JDK 并任意切换
  • 配置 Smart Link 接口时需注意的互斥命令
  • QT的下载和安装
  • nacos配置中心与服务注册中心
  • UE4 手把手教你做插件(1) 从代码引用插件
  • 【Mybatis源码解析】一级缓存和二级缓存源码解析
  • 你知道MES实施的要点吗?
  • 告诉你为什么为什么 SELECT COUNT(*) FROM table 在 InnoDB 引擎中比 MyISAM引擎中的速度慢
  • Redis 命令和Redis key键
  • 如何入侵服务器
  • 在Windows10上安装虚拟机---VMware 17 Pro下载与安装
  • 生命周期函数、组件
  • 蓝桥杯 stm32 PWM 测量频率