
Consider defining a bean of type ‘com.service.UserService‘ in your configuration解决方案
项目场景:
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”)注解。
👁️ 阅读量:0
© 版权声明:本文《Consider defining a bean of type ‘com.service.UserService‘ in your configuration解决方案》内容均为本站精心整理或网友自愿分享,如需转载请注明原文出处:https://www.zastudy.cn/wen/1686559088a291930.html。