Unsatisfied dependency expressed through field 'baseMapper'
使用MyBatisX自动生成Mapper接口,启动springboot项目时却报错
Error creating bean with name 'commentServiceImpl': Unsatisfied dependency expressed through field 'baseMapper';
...
- 原因:
自动生成的Mapper接口没有被扫描到 - 解决方法
- 给每个Mapper接口添加
@Mapper
注解 - 或添加一个配置类,用
@MapperScan
注解扫描Mapper所在包名
- 给每个Mapper接口添加
@Configuration
@MapperScan("com.xxx.mappper")
public class MyBatisPlusConfig {
}