springBoot整合Quartz报org.quartz.SchedulerException: Job instantiation failed

在整合Quartz的时候,新建了5个调度任务,启动后,第一个调度任务报了这样一个错误:

2019-11-12 02:36:25.796 [schedulerFactoryBean_QuartzSchedulerThread] ERROR org.quartz.core.ErrorLogger - An error occured instantiating job to be executed. job= 'pdf组.1'
org.quartz.SchedulerException: Job instantiation failed
	at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:47)
	at org.quartz.core.JobRunShell.initialize(JobRunShell.java:127)
	at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:392)
Caused by: java.lang.NoSuchMethodException: com.cect.quartz.job.ScheduleTask1.<init>()
	at java.lang.Class.getConstructor0(Class.java:3082)
	at java.lang.Class.getDeclaredConstructor(Class.java:2178)
	at org.springframework.util.ReflectionUtils.accessibleConstructor(ReflectionUtils.java:190)
	at org.springframework.scheduling.quartz.AdaptableJobFactory.createJobInstance(AdaptableJobFactory.java:61)
	at com.cect.quartz.utils.MyJobFactory.createJobInstance(MyJobFactory.java:34)
	at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:43)
	... 2 common frames omitted
2019-11-12 02:36:25.797 [schedulerFactoryBean_QuartzSchedulerThread] INFO  org.quartz.simpl.RAMJobStore - All triggers of Job pdf组.1 set to ERROR state.

但是另外四个调度任务可以正常执行,经过排查,发现第一个调度任务中注入的业务service是这样写的:

	private final ReportService reportService;

    public ScheduleTask1(ReportService reportService) {
        this.reportService = reportService;
    }

测试后发现,改成这样的写法就可以正常执行了:

	@Autowired
    private ReportService reportService;

聪明反被聪明误啊,希望能给遇到同样问题的童鞋提供一些帮助。

你可能感兴趣的:(Quartz)