报错Field Mapper in xxx.xxxServiceImpl required a bean of type ‘dao.xxxMapper‘ that could not be found

在这里插入图片描述
报错Field Mapper in xxx.xxxServiceImpl required a bean of type ‘dao.xxxMapper’ that could not be found

先说两个注释的区别:

  • @Mapper不需要配置扫描地址,通过xml里面的namespace里面的接口地址,生成了Bean后注入到Service层中。
  • @Repository需要在Spring中配置扫描地址,然后生成Dao层的Bean才能被注入到Service层中。

方法一:
@Repository改为@Mapper
在这里插入图片描述
方法二:
@Repository不改,在启动类中配置扫描地址
在这里插入图片描述
在这里插入图片描述


版权声明:本文为weixin_44377256原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。