在学习SpringBoot整合Mybatis-Plus的过程中,使用了一个新建项目进行测试,在进行测试依赖包工具进行测试时发现UserPlusDao使用自动装配注解时可以调用方法且不报错。但是执行方法后就出现如下报错,找不到合适的bean对象,通过查找网上的解决措施,发现是UserPlusDao的路径不对无法扫描到,经检查引入的包都没问题。
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.cn.TestMP': Unsatisfied dependency expressed through field 'userPlusDao';
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.cn.dao.UserPlusDao' available: expected at least 1 bean which qualifies as autowire candidate.
Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
最后发现是启动类这里缺少@MapperScan注解(新建的一个项目,所以漏掉了),所以说开发还是得多敲代码多记录,不然这稀奇古怪的问题每次解决起来还是要费点时间的。