标签:style io java ar art sp log on c
2、一个类搞定!!!,直接run
import org.quartz.CronTrigger;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.impl.StdSchedulerFactory;
import java.util.Date;
public class QuartzReport implements Job{
public void execute(JobExecutionContext cntxt) throws JobExecutionException {
System.out.println( "输出:"+cntxt.getJobDetail().getJobDataMap().get("name")+new Date());
}
public static void main(String[] args) {
try {
SchedulerFactory schedFact=new StdSchedulerFactory();
Scheduler sched=schedFact.getScheduler();
sched.start();
JobDetail jobDetail=new JobDetail("a","b",QuartzReport.class);
jobDetail.getJobDataMap().put("name","lucy");
CronTrigger trigger=new CronTrigger("c","d");
trigger.setCronExpression("0/1 * * * * ? " ); // 启动之后立即执行 每一秒继续重复。
sched.scheduleJob(jobDetail, trigger);
} catch (Exception e) {
e.printStackTrace();
}
}
}
*/
附:cronExpression配置说明
秒 0-59 , - * /
分 0-59 , - * /
小时 0-23 , - * /
日期 1-31 , - * ? / L W C
月份 1-12 或者 JAN-DEC , - * /
星期 1-7 或者 SUN-SAT , - * ? / L C #
年(可选) 留空, 1970-2099 , - * /
标签:style io java ar art sp log on c
原文地址:http://www.cnblogs.com/zhaofeng555/p/3977813.html