public class Jobfile implements Job {
public Jobfile() {
}
public void execute(JobExecutionContext context)
throws JobExecutionException {
System.out.println("execute!");
}
}
/**
* SimpleTrigger五个参数依次为:
* <p/>
* String triggername--名字
* <p/>
* String group--组别
* <p/>
* Date startTime--开始时间
* <p/>
* Date endTime--结束时间
* <p/>
* int repeatCount--重复次数,实际执行次数等于repeatCount+1
* <p/>
* Long repeatInterval--时间间隔
*/
public class Quartztest {
@SuppressWarnings({"static-access", "deprecation"})
public static void main(String args[]) {
SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
try {
Date endDate = new Date();
endDate.setMinutes(endDate.getMinutes() + 5);
Scheduler sched = schedFact.getScheduler();
sched.start();
//创建一个待调度的作业
JobDetail jobDetail = new JobDetail("myjob", sched.DEFAULT_GROUP, Jobfile.class);
//创建一个触发器控制作业的调度
SimpleTrigger trigger = new SimpleTrigger("myTrigger", sched.DEFAULT_GROUP, new Date(), endDate, 2, 5000L);
//调度作业
sched.scheduleJob(jobDetail, trigger);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public class Jobfile implements Job { public Jobfile() { } public void execute(JobExecutionContext context) throws JobExecutionException { System.out.println("execute!"); }...