项目使用Maven,在写一个定时功能时,使用的quartz与spring的整合,抛出了一个异常,异常如下:大致意思是无法注入promotionService.自己尝试了很多方法之后,google,让修改代理对象,使用cglb代理,并注入实体类,而不是接口,不成功.最终发现是maven没有update,导致pom.xml与最新的不一致;update以后便可以正常运行.
org.quartz.SchedulerException:Job instantiation failed [See nested exception:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name 'quartz.PromotionJob': Injection of autowireddependencies failed; nested exception isorg.springframework.beans.factory.BeanCreationException: Could not autowirefield: private .service.take_delivery.PromotionServicecn..quartz.PromotionJob.promotionService; nested exception isorg.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifyingbean of type [service.take_delivery.PromotionService] found fordependency: expected at least 1 bean which qualifies as autowire candidate forthis dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true),@org.springframework.beans.factory.annotation.Qualifier(value=promotionService)}]
atorg.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:45)
atorg.quartz.core.JobRunShell.initialize(JobRunShell.java:127)
atorg.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:375)
Caused by:org.springframework.beans.factory.BeanCreationException: Error creating beanwith name '.quartz.PromotionJob': Injection of autowireddependencies failed; nested exception isorg.springframework.beans.factory.BeanCreationException: Could not autowirefield: private .service.take_delivery.PromotionServicecn.quartz.PromotionJob.promotionService; nested exception isorg.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifyingbean of type [.service.take_delivery.PromotionService] found fordependency: expected at least 1 bean which qualifies as autowire candidate forthis dependency. Dependency annotations:{@org.springframework.beans.factory.annotation.Autowired(required=true),@org.springframework.beans.factory.annotation.Qualifier(value=promotionService)}
atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBean(AbstractAutowireCapableBeanFactory.java:302)
at.quartz.JobFactory.createJobInstance(JobFactory.java:20)
atorg.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:41)
...2 more
Caused by:org.springframework.beans.factory.BeanCreationException: Could not autowirefield: private
.service.take_delivery.PromotionService.quartz.PromotionJob.promotionService; nested exception isorg.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifyingbean of type [.service.take_delivery.PromotionService] found fordependency: expected at least 1 bean which qualifies as autowire candidate forthis dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true),@org.springframework.beans.factory.annotation.Qualifier(value=promotionService)}
atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
atorg.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
...6 more
Caused by:org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifyingbean of type [.service.take_delivery.PromotionService] found fordependency: expected at least 1 bean which qualifies as autowire candidate forthis dependency. Dependency annotations:{@org.springframework.beans.factory.annotation.Autowired(required=true),@org.springframework.beans.factory.annotation.Qualifier(value=promotionService)}
atorg.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1301)
atorg.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047)
atorg.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
...8 more