项目场景:

SpringBoot+MybatisPlus使用。


问题描述

Could not autowire. No beans of ‘UserMapper’ type found.


原因分析:

没有扫描到

因为这是SpringBoot整合Mybatis的代码,所以在Mapper接口类使用的是@Mapper注解。

但如果每个Mapper接口类都添加@Mapper注解比较麻烦,所以用了@MapperScan注解批量扫描Mapper接口类。


解决方案:

在xxxApplication启动类加上 @MapperScan(“com.xxx.xxx.mapper”)注解。

更多推荐

Consider defining a bean of type ‘com.service.UserService‘ in your configuration