问题描述
SpringBoot3 集成Mybatis-Plus时报错
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'migrationServiceImpl': Unsatisfied dependency expressed through field 'baseMapper':
Error creating bean with name 'migrationMapper' defined in file [D:\PROJECT\JAVA\SpringBoot_pro\SpringBoot-MMRLC\target\classes\edu\swpu\mmrlc\mapper\MigrationMapper.class]:
Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
原因分析:
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.2</version>
</dependency>
mybatis-plus-boot-starter版本过低,如果要使用SpringBoot3,mybatis-plus-boot-starter的版本要求3.5.3及以上
解决方案:
引入高版本依赖
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3.2</version>
</dependency>
同时根据其他帖子说明,只引入mybatis-plus-boot-starter这一个依赖就好,不要再引入其他mybatis或mybatis-plus相关依赖