spring boot 报错Could not autowire. No beans of 'BookMapper' type found. less... (Ctrl+F1)

最近使用spring boot+mybatis时出现了这个错误;

spring boot 报错Could not autowire. No beans of 'BookMapper' type found. less... (Ctrl+F1)

看IDEA的提示是这个mapper接口没有被注入,不是一个bean,看百度很多人都说是在IDEA中降低提示级别,这种方法只能让你看不到报红,熟悉@Autowired注解就知道怎么解决了,

spring boot 报错Could not autowire. No beans of 'BookMapper' type found. less... (Ctrl+F1)

我们在mapper接口上添加@Component注解,然后就没问题了:

spring boot 报错Could not autowire. No beans of 'BookMapper' type found. less... (Ctrl+F1)