Quartz配置问题

1.由于项目需求需要用到定时任务,因此我做了一个demo。我照着官方文档抄下来的,结果报了下面的错误信息。令我百思不得其解,后来各种资料都没找到问题,一下是我刚开始的spring配置文件,再下面是我的错误信息。

	

	 
		
		
	 

	
		
		
	 

	
		
			
				
			
		
	
 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean#1' defined in file [E:\demo\*-*-service\target\classes\META-INF\spring\quartz.xml]: Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: The job (DEFAULT.myJob) referenced by the trigger does not exist.
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:681)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
	at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:93)
	at com.alibaba.dubbo.container.spring.SpringContainer.start(SpringContainer.java:50)
	at com.alibaba.dubbo.container.Main.main(Main.java:80)
	at com.ucloudlink.bss.ucp.Main.main(Main.java:9)
Caused by: org.quartz.JobPersistenceException: The job (DEFAULT.myJob) referenced by the trigger does not exist.
	at org.quartz.simpl.RAMJobStore.storeTrigger(RAMJobStore.java:422)
	at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:932)
	at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:258)
	at org.springframework.scheduling.quartz.SchedulerAccessor.addTriggerToScheduler(SchedulerAccessor.java:357)
	at org.springframework.scheduling.quartz.SchedulerAccessor.registerJobsAndTriggers(SchedulerAccessor.java:289)
	at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:516)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
	... 14 more
解决问题方法:最后我查阅公司之前代码库,发现问题,竟然是因为我没给SchedulerFactoryBean加一个ID

改后的spring的配置文件

	
		
		
	 

	
		
		
	 

	 class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		
			
				
			
		
	 


你可能感兴趣的:(Quartz配置问题)