Unsatisfied dependency expressed through field 'baseMapper'

使用MyBatisX自动生成Mapper接口,启动springboot项目时却报错

Error creating bean with name 'commentServiceImpl': Unsatisfied dependency expressed through field 'baseMapper';
...

  • 原因:
    自动生成的Mapper接口没有被扫描到
  • 解决方法
    1. 给每个Mapper接口添加@Mapper注解
    2. 或添加一个配置类,用@MapperScan注解扫描Mapper所在包名
@Configuration
@MapperScan("com.xxx.mappper")
public class MyBatisPlusConfig {
}
posted @ 2022-07-08 16:41  DaleLee  阅读(1895)  评论(0)    收藏  举报