问题

项目报异常:

1
2
Unsatisfied dependency expressed through field 'articleService';
Unsatisfied dependency expressed through field 'baseMapper';

解决方法

应该是Mapper没有被扫描到

  • 方法一:添加@MapperScan("xxx.xxx.xxx")注解, xxx.xxx.xxx就是你Mapper所在的包

    1
    2
    3
    4
    5
    6
    7
    @SpringBootApplication
    @MapperScan("org.bailang.mapper")
    public class BaiLangBlogApplication {
    public static void main(String[] args) {
    SpringApplication.run(BaiLangBlogApplication.class, args);
    }
    }

  • 方法二:在mapper接口上面添加@Mapper注解

    1
    2
    3
    4
    @Mapper
    public interface ArticleMapper extends BaseMapper<Article> {

    }

  • 重新编译项目,编译成功

参考链接