SpringBoot 3 版本 mybatis-plus 踩坑记录:Property ‘sqlSessionFactory‘ or ‘sqlSessionTemplate‘ are required
毕竟 SpringBoot 3.x 刚出,搭建的时候已经踩了一堆坑了,估计也是版本问题,去 mybatis-plus 的 Github 上去看,在 SpringBoot 3.x 的兼容性上确实还有一些问题,推荐使用 3.5.3 及以上版本。
·
玩玩 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-plus 的 Github 上去看,在 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
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)