首页 > 编程知识 正文

componentscan作用,@mapper注解的使用

时间:2023-05-03 10:58:42 阅读:28366 作者:2064

1、首先@MapperScan和@ComponentScan是扫描包

2、@ComponentScan是一个组件扫描注释,用于扫描类似@Controller@Service@Repository的类,主要是定义扫描路径并从中进行组装

3,@MapperScan是扫描mapper类的注释,每个mapper类不必带有@MapperScan

这两个评论可以同时使用。

3358 www.Sina.com/adolph http://www.Sina.com/@ mappers can和@ComponentScan的区别-观海闻涛丶-博客园接下来是我的问题:

由于main方法使用@ComponentScan而不是@MapperScan,因此发生了错误。

injectionofresourcedependenciesfailed; nestedexceptionisorg.spring framework.beans.factory.beancreationexception : errorcreatingbeanwithname ' managerserservice ork.beans.factory.nosuchbeandefinitionexception 3360 noqualifyingbeanoftype [ com.add ype ] foundfordependency 3360 expected atleast1beanwhichqualifiesasautowirecandidateforthisdependency annotations 3360 { @ TTT e,mappedName=,description=,name=,type=class java.lang.Object,authentication

解决:只需返回@MapperScan即可解决

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。