1.核心类
api测试
package com.lxl.dsbf.quartz;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
import java.util.GregorianCalendar;
public class HelloQuartz {
public static void main(String[] args) throws SchedulerException {
//1.scheduler调度器
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
//2.触发器
SimpleTrigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger1", "group1")
.startNow()
.withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(2).withRepeatCount(10))
.endAt(new GregorianCalendar(2020, 11, 3, 13, 23, 34).getTime())
.build();
//3.JobDetail
JobDetail jobDetail = JobBuilder.newJob(HelloJob.class).withIdentity("job1", "group1").build();
//4.将JobDetail和触发器增加到调度器中
scheduler.scheduleJob(jobDetail,trigger);
//5.启动,调度器开始工作
scheduler.start();
}
}