springboot集成mybatis-plus时注入mapper失败报错

异常信息如下:

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2018-09-03 14:21:14.274 ERROR 14496 — [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userController’: Unsatisfied dependency expressed through field ‘userService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userServiceImpl’: Unsatisfied dependency expressed through field ‘baseMapper’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.baomidou.springboot.cususer.mapper.UserMapper’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor A u t o w i r e d F i e l d E l e m e n t . i n j e c t ( A u t o w i r e d A n n o t a t i o n B e a n P o s t P r o c e s s o r . j a v a : 587 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . a n n o t a t i o n . I n j e c t i o n M e t a d a t a . i n j e c t ( I n j e c t i o n M e t a d a t a . j a v a : 91 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . a n n o t a t i o n . A u t o w i r e d A n n o t a t i o n B e a n P o s t P r o c e s s o r . p o s t P r o c e s s P r o p e r t y V a l u e s ( A u t o w i r e d A n n o t a t i o n B e a n P o s t P r o c e s s o r . j a v a : 373 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . p o p u l a t e B e a n ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 1350 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . d o C r e a t e B e a n ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 580 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . c r e a t e B e a n ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 503 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t B e a n F a c t o r y . l a m b d a AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1350) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:580) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1350) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:580) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.support.AbstractBeanFactory.lambdadoGetBean 0 ( A b s t r a c t B e a n F a c t o r y . j a v a : 317 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . D e f a u l t S i n g l e t o n B e a n R e g i s t r y . g e t S i n g l e t o n ( D e f a u l t S i n g l e t o n B e a n R e g i s t r y . j a v a : 222 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t B e a n F a c t o r y . d o G e t B e a n ( A b s t r a c t B e a n F a c t o r y . j a v a : 315 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t B e a n F a c t o r y . g e t B e a n ( A b s t r a c t B e a n F a c t o r y . j a v a : 199 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . D e f a u l t L i s t a b l e B e a n F a c t o r y . p r e I n s t a n t i a t e S i n g l e t o n s ( D e f a u l t L i s t a b l e B e a n F a c t o r y . j a v a : 760 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . A b s t r a c t A p p l i c a t i o n C o n t e x t . f i n i s h B e a n F a c t o r y I n i t i a l i z a t i o n ( A b s t r a c t A p p l i c a t i o n C o n t e x t . j a v a : 869 )   [ s p r i n g − c o n t e x t − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . A b s t r a c t A p p l i c a t i o n C o n t e x t . r e f r e s h ( A b s t r a c t A p p l i c a t i o n C o n t e x t . j a v a : 550 )   [ s p r i n g − c o n t e x t − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . w e b . s e r v l e t . c o n t e x t . S e r v l e t W e b S e r v e r A p p l i c a t i o n C o n t e x t . r e f r e s h ( S e r v l e t W e b S e r v e r A p p l i c a t i o n C o n t e x t . j a v a : 140 )   [ s p r i n g − b o o t − 2.0.3. R E L E A S E . j a r : 2.0.3. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n . r e f r e s h ( S p r i n g A p p l i c a t i o n . j a v a : 759 )   [ s p r i n g − b o o t − 2.0.3. R E L E A S E . j a r : 2.0.3. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n . r e f r e s h C o n t e x t ( S p r i n g A p p l i c a t i o n . j a v a : 395 )   [ s p r i n g − b o o t − 2.0.3. R E L E A S E . j a r : 2.0.3. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n . r u n ( S p r i n g A p p l i c a t i o n . j a v a : 327 )   [ s p r i n g − b o o t − 2.0.3. R E L E A S E . j a r : 2.0.3. R E L E A S E ] a t c o m . b a o m i d o u . s p r i n g b o o t . A p p l i c a t i o n . m a i n ( A p p l i c a t i o n . j a v a : 47 ) [ c l a s s e s / : n a ] C a u s e d b y : o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . U n s a t i s f i e d D e p e n d e n c y E x c e p t i o n : E r r o r c r e a t i n g b e a n w i t h n a m e ′ u s e r S e r v i c e I m p l ′ : U n s a t i s f i e d d e p e n d e n c y e x p r e s s e d t h r o u g h f i e l d ′ b a s e M a p p e r ′ ; n e s t e d e x c e p t i o n i s o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . N o S u c h B e a n D e f i n i t i o n E x c e p t i o n : N o q u a l i f y i n g b e a n o f t y p e ′ c o m . b a o m i d o u . s p r i n g b o o t . c u s u s e r . m a p p e r . U s e r M a p p e r ′ a v a i l a b l e : e x p e c t e d a t l e a s t 1 b e a n w h i c h q u a l i f i e s a s a u t o w i r e c a n d i d a t e . D e p e n d e n c y a n n o t a t i o n s : @ o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . a n n o t a t i o n . A u t o w i r e d ( r e q u i r e d = t r u e ) a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . a n n o t a t i o n . A u t o w i r e d A n n o t a t i o n B e a n P o s t P r o c e s s o r 0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] at com.baomidou.springboot.Application.main(Application.java:47) [classes/:na] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.baomidou.springboot.cususer.mapper.UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor 0(AbstractBeanFactory.java:317) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) [springcontext5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) [springcontext5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) [springboot2.0.3.RELEASE.jar:2.0.3.RELEASE]atorg.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [springboot2.0.3.RELEASE.jar:2.0.3.RELEASE]atorg.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [springboot2.0.3.RELEASE.jar:2.0.3.RELEASE]atorg.springframework.boot.SpringApplication.run(SpringApplication.java:327) [springboot2.0.3.RELEASE.jar:2.0.3.RELEASE]atcom.baomidou.springboot.Application.main(Application.java:47)[classes/:na]Causedby:org.springframework.beans.factory.UnsatisfiedDependencyException:ErrorcreatingbeanwithnameuserServiceImpl:UnsatisfieddependencyexpressedthroughfieldbaseMapper;nestedexceptionisorg.springframework.beans.factory.NoSuchBeanDefinitionException:Noqualifyingbeanoftypecom.baomidou.springboot.cususer.mapper.UserMapperavailable:expectedatleast1beanwhichqualifiesasautowirecandidate.Dependencyannotations:@org.springframework.beans.factory.annotation.Autowired(required=true)atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessorAutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1350) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:580) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean 0 ( A b s t r a c t B e a n F a c t o r y . j a v a : 317 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . D e f a u l t S i n g l e t o n B e a n R e g i s t r y . g e t S i n g l e t o n ( D e f a u l t S i n g l e t o n B e a n R e g i s t r y . j a v a : 222 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t B e a n F a c t o r y . d o G e t B e a n ( A b s t r a c t B e a n F a c t o r y . j a v a : 315 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t B e a n F a c t o r y . g e t B e a n ( A b s t r a c t B e a n F a c t o r y . j a v a : 199 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . c o n f i g . D e p e n d e n c y D e s c r i p t o r . r e s o l v e C a n d i d a t e ( D e p e n d e n c y D e s c r i p t o r . j a v a : 251 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . D e f a u l t L i s t a b l e B e a n F a c t o r y . d o R e s o l v e D e p e n d e n c y ( D e f a u l t L i s t a b l e B e a n F a c t o r y . j a v a : 1138 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . D e f a u l t L i s t a b l e B e a n F a c t o r y . r e s o l v e D e p e n d e n c y ( D e f a u l t L i s t a b l e B e a n F a c t o r y . j a v a : 1065 )   [ s p r i n g − b e a n s − 5.0.7. R E L E A S E . j a r : 5.0.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . a n n o t a t i o n . A u t o w i r e d A n n o t a t i o n B e a n P o s t P r o c e s s o r 0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor 0(AbstractBeanFactory.java:317) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) [springbeans5.0.7.RELEASE.jar:5.0.7.RELEASE]atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessorAutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
… 17 common frames omitted
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.baomidou.springboot.cususer.mapper.UserMapper’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1509) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
… 30 common frames omitted
表示service注入mapper失败

/**
*

  • User 表数据服务层接口实现类

*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, Cususer> implements IUserService {

@Override
public boolean deleteAll() {
	return retBool(baseMapper.deleteAll());
}

@Override
public List<Cususer> selectListBySQL() {
	return baseMapper.selectListBySQL();
}

@Override
public List<Cususer> selectListByWrapper(Wrapper wrapper) {
	return baseMapper.selectListByWrapper(wrapper);
}

}
UserMapper不受spring管理所有没有注入

/**

  • User 表数据库控制层接口
    */

public interface UserMapper extends SuperMapper {

/**
 * 自定义注入方法
 */
int deleteAll();

@Select("select test_id as id, name, age, test_type from cususer")
List<Cususer> selectListBySQL();

List<Cususer> selectListByWrapper(@Param("ew") Wrapper wrapper);

}
要想实现注入必须在mapper上添加标签@Mapper

/**

  • User 表数据库控制层接口
    */
    @Mapper
    public interface UserMapper extends SuperMapper {
    或者指定mapper的扫描范围

@EnableTransactionManagement
@SpringBootApplication
@MapperScan(“com.baomidou.springboot..mapper")
@ComponentScan(basePackages = {
“com.baomidou.springboot.config”,
"com.baomidou.springboot.
.controller”,
“com.baomidou.springboot.*.service”})
public class Application {
mybatis-config中只是会为对应的mapper创建代理类,而想真正包装成bean,注入到spring容器中,还是需要靠AutoConfiguredMapperScannerRegistrar,它会根据扫描@Mapper注释或是@MapperScan指定的包下的接口,将其注册为bean。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值