CronTriggerRunner

package  hvp.spring.quartz.simpleTrigger;

import  java.text.ParseException;

import  org.quartz.CronExpression;
import  org.quartz.CronTrigger;
import  org.quartz.JobDetail;
import  org.quartz.Scheduler;
import  org.quartz.SchedulerException;
import  org.quartz.SchedulerFactory;
import  org.quartz.impl.StdSchedulerFactory;

public   class  CronTriggerRunner
{
    
public void test() throws ParseException, SchedulerException
    
{
        JobDetail jobDetail 
= new JobDetail("job1_2""jGroup1",
                SimpleJob.
class);
        CronTrigger cronTrigger 
= new CronTrigger("trigger1_2""tgroup1");
        CronExpression cexp 
= new CronExpression("0/5 * * * * ?");
        cronTrigger.setCronExpression(cexp);
        
        
// 生成高度器
        SchedulerFactory schedulerFactory = new StdSchedulerFactory();
        Scheduler scheduler 
= schedulerFactory.getScheduler();
        
        
// 关联任务和触发器
        scheduler.scheduleJob(jobDetail, cronTrigger);
        
// 开始调度
        scheduler.start();
    }

    
    
public static void main(String args[]) throws ParseException, SchedulerException{
        CronTriggerRunner ctr 
= new CronTriggerRunner();
        ctr.test();
    }

}

你可能感兴趣的:(spring,quartz)