报错类型:找不到Mapper的bean,No qualifying bean of type 'com.aiit.mapper.XXX'
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'com.aiit.MybatisplueApplicationTests':
Unsatisfied dependency expressed through field 'bookMapper':
No qualifying bean of type 'com.aiit.mapper.BookMapper' available:
expected at least 1 bean which qualifies as autowire candidate. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}
他意思就是说你的Mapper没有被注入到容器中,找不到容器中的bean
总共就检查两点:
1.看你的Mapper文件中是否写了注解@Mapper
如何你注解也写了,发现不起作用,那么你尝试一下第二种方法:
2.修改mybatis-plus的依赖版本
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3</version>
</dependency>
注意:springboot3以上整合Mybatisplus时,mybatisplus版本必须高于3.5.3以上