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即可解决