zoukankan      html  css  js  c++  java
  • 定时任务(二)

    package com.sf.dangbao.core.TimeTask;

    import org.quartz.*;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;


    /**
    * @author pxz
    * @date 2019/4/28
    * @description :
    */
    @Configuration
    public class QuartzJobConfig {

    @Value("${send.corn}")
    private String sendTaskJobCorn;

    @Value("${send.tomorrow}")
    private String tomorrowJobCorn;

    @Bean
    public JobDetail distributeTaskJob() {
    return JobBuilder.newJob(DistributeTaskJob.class).withIdentity("distributeTaskJob").storeDurably().build();
    }

    @Bean
    public JobDetail tomorrowTaskJob(){
    return JobBuilder.newJob(TomorrowTaskJob.class).withIdentity("tomorrowTaskJob").storeDurably().build();
    }

    @Bean
    public Trigger storeCheckJobTrigger() {
    CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(sendTaskJobCorn);
    return TriggerBuilder.newTrigger().forJob(distributeTaskJob()).withIdentity("storeCheckJobTrigger")
    .withSchedule(scheduleBuilder).build();
    }

    @Bean
    public Trigger tomorrowJobTrigger() {
    CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(tomorrowJobCorn);
    return TriggerBuilder.newTrigger().forJob(tomorrowTaskJob()).withIdentity("tomorrowJobTrigger")
    .withSchedule(scheduleBuilder).build();
    }
    }
  • 相关阅读:
    状态模式
    迭代器模式和组合模式
    模板方法模式
    适配器模式和外观模式
    principle06
    principle05
    命令模式
    单例模式
    工厂模式
    day38(表相关内容)
  • 原文地址:https://www.cnblogs.com/pxzbky/p/11911322.html
Copyright © 2011-2022 走看看