首页 > 数据库 >SpringBoot升级到3.3.2版本,JDK升级到17,引入Mybatis-plus后启动报错:Property 'sqlSessionFactory' or 'sq

SpringBoot升级到3.3.2版本,JDK升级到17,引入Mybatis-plus后启动报错:Property 'sqlSessionFactory' or 'sq

时间:2024-07-23 16:57:13浏览次数:12  
标签:23T15 sqlSessionFactory xxx 升级 plus Error mybatis 报错

【问题描述】

2024-07-23T15:16:07.174+08:00 WARN 2604 --- [questionnaire] [ main] ConfigServletWebServerApplicationContext :
Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'TActivitySessionServiceImpl': Unsatisfied dependency expressed through field 'baseMapper':
Error creating bean with name 'TActivitySessionMapper' defined in file [D:\xxx\yyy\target\classes\com\xxx\yyy\zzz\mapper\TxxxMapper.class]:
Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
2024-07-23T15:16:07.176+08:00 INFO 2604 --- [questionnaire] [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2024-07-23T15:16:07.206+08:00 INFO 2604 --- [questionnaire] [ main] .s.b.a.l.ConditionEvaluationReportLogger :

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-07-23T15:16:07.225+08:00 ERROR 2604 --- [questionnaire] [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'TActivitySessionServiceImpl': Unsatisfied dependency expressed through field 'baseMapper': Error creating bean with name 'TActivitySessionMapper' defined in file [D:\xxx\yyy\target\classes\com\xxx\xxx\yyy\mapper\TxxxMapper.class]: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required

 

【原因分析】

SpringBoot2.x版本和JDK8没有这个问题,当SpringBoot升级到3.3.2版本,JDK升级到17版本,再引入Mybatis-plus后就会启动报错,不能自动加载sqlSessionFactory。

 

【解决方案】

需要升级mybatis-plus的坐标依赖:

由:mybatis-plus-boot-starter

 

<!--<dependency>

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

修改为:mybatis-plus-spring-boot3-starter
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
<version>3.5.5</version>
</dependency>

标签:23T15,sqlSessionFactory,xxx,升级,plus,Error,mybatis,报错
From: https://www.cnblogs.com/heyi-77/p/18318916

相关文章