SpringBoot 3 版本 mybatis-plus 踩坑记录:Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required

玩玩 Spring 3 ,对接数据库的时候报错了,错误信息如下:

Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 
	'sqlSessionTemplate' are required
	at org.springframework.util.Assert.notNull(Assert.java:204) ~[spring-core-
		6.0.6.jar:6.0.6]
	at org.mybatis.spring.support.SqlSessionDaoSupport.checkDaoConfig(SqlSessionDaoSupport.java:
		122) ~[mybatis-spring-2.0.7.jar:2.0.7]
	at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:73) 
		~[mybatis-spring-2.0.7.jar:2.0.7]
	at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44) 
		~[spring-tx-6.0.6.jar:6.0.6]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods
		(AbstractAutowireCapableBeanFactory.java:1808) ~[spring-beans-6.0.6.jar:6.0.6]

参考旧得项目搞得,按说应该没问题,依赖如下:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <version>3.0.4</version>
</dependency>

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

毕竟 SpringBoot 3.x 刚出,搭建的时候已经踩了一堆坑了,估计也是版本问题,去 mybatis-plusGithub 上去看,在 SpringBoot 3.x 的兼容性上确实还有一些问题,推荐使用 3.5.3 及以上版本。

Issue 地址:https://github.com/baomidou/mybatis-plus/issues/4971

在这里插入图片描述
如果后续有更新的版本的话,建议持续升级一下。

【重要】
Mybaits-Plus 3.5.3 有紧急 bug,建议直接使用 3.5.3.1
在这里插入图片描述

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

完美解决,继续折腾;后续的新项目直接 JDK17 + SpringBoot 3.x 走起!!!

在这里插入图片描述
个人博客:Roc’s Blog

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Roc.Chang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值