Consider defining a bean of type ‘com.service.UserService‘ in your configuration解决方案

编程知识 更新时间:2023-05-02 05:20:48

项目场景:

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

本文发布于:2023-04-26 05:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/7b2e6278e92d5b8aa1f9ab75b01fd465.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:解决方案   type   bean   defining   configuration

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 104290文章数
  • 26210阅读数
  • 0评论数