SpringBoot 3.x整合MyBatis-Plus时报错 Invalid bean definition with name ‘xxxMapper‘ defined in flle
问题描述
在搭建Spring Boot 项目整合 Mybatis-Plus 时产生报错
Invalid bean definition with name 'XXXMapper' defined in file [C:\Users\19609\Desktop\OrderApp\order_boot\target\classes\com\louis\order\mapper\UserMapper.class]: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String
排查路径
1.检查mapper文件是否添加@Mapper注解
2.检查启动类是否添加@MapperScan注解
3.检查application.yml文件配置
mybatis-plus:
mapper-locations: classpath*:/mapper/**/*.xml
type-aliases-package: com.louis.xxx.entity # 你的实体类包路径
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
4.重新mvn clean install
解决方案
发现都没什么问题,最后找了一下mybatisPlus官网,发现是maven依赖不匹配导致的。还是因为之前一直用的Spring Boot2.x导致的思维定式,都没注意这么简单的细节。
Spring Boot 2.x
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.11</version>
</dependency>
Spring Boot 3.x
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
<version>3.5.11</version>
</dependency>
详情请访问:MybatisPlus官网

浙公网安备 33010602011771号