【使用案例2】: [创建job类,使用CronSchedulerBuilder]: import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; public class SecondJob implements Job{ public void execute(JobExecutionContext context) throws JobExecutionException { System.out.println("使用crontrigger...."); } } [创建测试类]: import org.quartz.CronScheduleBuilder; import org.quartz.JobBuilder; import org.quartz.JobDetail; import org.quartz.Scheduler; import org.quartz.Trigger; import org.quartz.TriggerBuilder; import org.quartz.impl.StdSchedulerFactory; import job.SecondJob; public class SecondScheduler { public static void main(String[] args) throws Exception { //创建一个定时器对象 Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); //创建一个jobDetail对象 JobDetail jobDetail = JobBuilder.newJob(SecondJob.class).withIdentity("job_2", "group_2").build(); //创建一trigger Trigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger_2", "group_2") .startNow().withSchedule(CronScheduleBuilder.cronSchedule("0 17 1 * * ?")).build(); scheduler.scheduleJob(jobDetail,trigger); scheduler.start(); } }