刚学在Spring Boot项目整合Mybatis实现增删改查的过程中测试类出现 Could not autowire. No beans of 'RoleMapper' type found.

在Spring Boot项目整合Mybatis实现增删改查的过程中测试类出现Could not autowire. No beans of 'RoleMapper' type found.如下图

img

img

img

img

img

在mapper上加个@Repository看看

看一下mapper上加注解了没

Mapper 接口没有注册为 spring bean,在你的 Task001Application 配置类上添加 @MapperScan("com.test.mapper") 注解

启动类上面把这三个注解加进去试一下。
@Configuration
@EnableAutoConfiguration
@ComponentScan