> 技术文档 > Invalid value type for attribute ‘factoryBeanObjectType‘: java.lang.String_invalid value type for attribute \'factorybeanobjec

Invalid value type for attribute ‘factoryBeanObjectType‘: java.lang.String_invalid value type for attribute \'factorybeanobjec

目录

一、问题

二、错误原因分析

三、可能原因

(一) Mapper 接口扫描配置错误

(二) 验证依赖版本

1. Spring Boot2

2. Spring Boot 3

(三) 清理项目缓存

一、问题

Invalid bean definition with name \'userMapper\' defined in file [E:\\my_project\\idea\\ww-ai-agent\\target\\classes\\com\\ww\\wwaiagent\\mapper\\UserMapper.class]: Invalid value type for attribute \'factoryBeanObjectType\': java.lang.String

二、错误原因分析

factoryBeanObjectType 是 Spring 中用于指定 FactoryBean 创建的对象类型的属性。错误信息表明,Spring 期望这个属性是一个类(Class),但实际得到的是字符串(String)。

三、可能原因

(一) Mapper 接口扫描配置错误

@MapperScan 或 XML 配置中指定的包路径不正确。

一般在启动类中需要配置MapperScan

(二) 验证依赖版本

使用与 Spring Boot 兼容的 MaBatis-Spring-Boot-Starter 版本

通过 MyBatis-Plus 官网可以看到

1. Spring Boot2

 com.baomidou mybatis-plus-boot-starter 3.5.12

2. Spring Boot 3

 com.baomidou mybatis-plus-spring-boot3-starter 3.5.12

不同的Spring Boot 版本有不同的引入方式(我就是这里引入错误)

(三) 清理项目缓存

消除可能的编译缓存问题