Quartz计划程序在Spring批处理管理设置中不工作

Quartz计划程序在Spring批处理管理设置中不工作,spring,quartz-scheduler,spring-batch-admin,Spring,Quartz Scheduler,Spring Batch Admin,背景: 我们有一些由cron作业触发的springbatch(作为引导应用程序)管理的作业,我正在用quartz替换cron,并添加springbatchadmin来管理作业 到目前为止,我能够通过SpringBatch管理控制台运行作业,当quartz试图触发作业执行时,就会出现问题。JobLauncher、JobLocator对象为空,这是自动连接的。请注意,我使用的是基于Java的配置,而不是XML @PersistJobDataAfterExecution @DisallowConcur

背景: 我们有一些由cron作业触发的springbatch(作为引导应用程序)管理的作业,我正在用quartz替换cron,并添加springbatchadmin来管理作业

到目前为止,我能够通过SpringBatch管理控制台运行作业,当quartz试图触发作业执行时,就会出现问题。JobLauncher、JobLocator对象为空,这是自动连接的。请注意,我使用的是基于Java的配置,而不是XML

@PersistJobDataAfterExecution
@DisallowConcurrentExecution
@Component
@EnableBatchProcessing
public class GatewayReconciliationQuartzJob extends QuartzJobBean {

    private static final String JOB_NAME = "GatewayReconciliationJob";

    @Autowired
    BatchJobLauncher batchJobLauncher;

    @Autowired
    private JobLocator jobLocator;

    @Autowired
    private JobLauncher jobLauncher;

    @Override
    protected void executeInternal(JobExecutionContext context) {

        try {

            if (null == jobLauncher) {
                LOG.info("JobLauncher is null ");
            }

            if (null == jobLocator) {
                LOG.info("jobLocator is null ");
            }

            LOG.info(String.format("Now really Starting Batch Job : %s", JOB_NAME));

            JobParametersBuilder builder = new JobParametersBuilder();
            builder.addDate("date", new Date());

            this.jobLauncher.run(this.jobLocator.getJob(JOB_NAME), builder.toJobParameters());

        } catch (JobExecutionAlreadyRunningException | JobInstanceAlreadyCompleteException | JobParametersInvalidException | NoSuchJobException | JobRestartException e) {
            LOG.error("Error executing job", e);
            throw new RuntimeException(e);
        }

    }
}
发件人: 将以下行添加到
executeInternal
方法的开头:

@Override
public void executeInternal(final JobExecutionContext context) throws JobExecutionException {
    // Adding this autowires everything as needed
    SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);    
    ...
}