项目场景:
在我们刚开始创建一个springboot项目时,肯定要配置各种的依赖,有的新手可能会出现一些依赖的问题,这里列举一个经典的配置问题
问题描述
在springboot+mybatis项目启动时,报错:org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name ‘userMapper’ defined in file [/Users/idea/big-event/target/classes/com/dongyang/mapper/UserMapper.class]: Invalid value type for attribute ‘factoryBeanObjectType’: java.lang.String,图片如下:
原因分析:
由于springboot版本过高,与mybatis版本不对应,导致mapper无法被找到
springboot:
mybatis:
解决方案:
我们打开pom文件,然后降低springboot版本,我这里使用的是2.7.9,然后mybatis版本使用的是2.2.2,
springboot:
mybatis:
版本修改过后,重新启动springboot项目:
这样就启动成功了,如果你也遇到这样的问题,那么大概率就是springboot与mybatis的版本没有对应上,修改版本就可以了。