quartz scheduler+spring:创建触发器时如何从jobstore获取初始cron表达式?

2nc8po8w  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(402)

使用jobstoretx,如何获取数据库中已经存在的trigger的cron表达式?
我试过了,但没用。

@Bean
    public CronTriggerFactoryBean cancelamentoTrigger(@Qualifier("cancelamentoJobDetail") JobDetail job, JobStore jobStore) throws JobPersistenceException {
        CronTriggerFactoryBean trigger = new CronTriggerFactoryBean();
        trigger.setJobDetail(job);

        TriggerKey cancelamentoTrigger = new TriggerKey("cancelamentoTrigger");
        if (jobStore.checkExists(cancelamentoTrigger)) {
            trigger.setCronExpression(((CronTrigger) scheduler.getTrigger(cancelamentoTrigger)).getCronExpression());
        } else {
            trigger.setCronExpression("0/30 0/1 * 1/1 * ? *");
        }

        return trigger;
    }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题