Spring Boot 配置定时任务quartz报错[The job (DEFAULT.job1) referenced by the trigger does not exist.]

发布于 2022-05-02 10:13:06 字数 4985 浏览 884 评论 8

我在spring boot里面配置了如下任务

@Bean(name = "schedulerFactoryBean")
	public SchedulerFactoryBean createSchedulerFactoryBean()throws Exception
	{
		SchedulerFactoryBean bean = new SchedulerFactoryBean();

		JobDetail job1 = newJob(SimpleJob.class).withIdentity("job1", "group1").storeDurably(true).build();
	
		CronTrigger trigger1 = newTrigger().withIdentity("trigger1", "group1").forJob("job1").withSchedule(cronSchedule("0/2 * * * * ?")).build();
	        
		bean.setJobDetails(job1);
		bean.setTriggers(trigger1);
		
		return bean;
	}



然而,启动报错了。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'schedulerFactoryBean' defined in com.pp.App2: Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: The job (DEFAULT.job1) referenced by the trigger does not exist.
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
	at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
	at com.pp.App2.main(App2.java:73) [classes/:na]
Caused by: org.quartz.JobPersistenceException: The job (DEFAULT.job1) referenced by the trigger does not exist.
	at org.quartz.simpl.RAMJobStore.storeTrigger(RAMJobStore.java:422) ~[quartz-2.2.2.jar:na]
	at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:932) ~[quartz-2.2.2.jar:na]
	at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:258) ~[quartz-2.2.2.jar:na]
	at org.springframework.scheduling.quartz.SchedulerAccessor.addTriggerToScheduler(SchedulerAccessor.java:312) ~[spring-context-support-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.scheduling.quartz.SchedulerAccessor.registerJobsAndTriggers(SchedulerAccessor.java:235) ~[spring-context-support-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:512) ~[spring-context-support-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
	... 16 common frames omitted


spring boot使用的版本是:1.3.3.RELEASE

请问,这是什么错误。怎么回事

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

星星的軌跡 2022-05-06 08:25:27

我项目里面有很多计划任务要跑,我想要对指定(某个)的任务进行停止,启动 这个spring boot支持吗?

怪异←思﹩ 2022-05-06 08:22:16

看这个bean从哪冒出来的 ? 这个bean注解去掉 或者配置好 

葬心 2022-05-06 07:16:57

是我帖代码的时候,弄错了。 就是第一个里面配置的bean

海夕 2022-05-06 06:58:04

schedulerFactoryBean2  你有这个bean 吗?

口干舌燥 2022-05-05 19:59:13

什么意思,怎么解决

当梦初醒 2022-05-05 16:37:54

@西夏一品堂 触发器没关联上

小忆控 2022-05-05 15:23:15

怎么解决的,楼主?

吖咩 2022-05-05 04:27:49

The job (DEFAULT.job1) referenced by the trigger does not exist.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文