任何人都可以帮我将以下逻辑更改为较新版本的Quartz-2.2.1。
JobDetail jobDetail = new JobDetail ( getName(), getClName(), EventJob.class())
和
Trigger trigger = new CronTrigger ("schedule name", "scheduled",
jobDetail.getName(), jobDetail.getGroup(),
" 0 0/5 * * * ? ",
getTimeZone());
你能帮我解决这个问题吗? 问候 雷卡
答案 0 :(得分:0)
你需要这样的东西:
SchedulerFactory schedulerFactory = new StdSchedulerFactory();
Scheduler scheduler = schedulerFactory.getScheduler();
// Job Detail
JobDetail jobDetail = newJob(EventJob.class)
.withIdentity(getName(), getClName())
.build();
// Trigger
CronTrigger trigger = newTrigger().withIdentity("schedule name","scheduled").forJob(jobDetail.getKey().getName(), jobDetail.getKey().getGroup()).withSchedule(cronSchedule(" 0 0/5 * * * ? ").inTimeZone(getTimeZone())).build();
scheduler.scheduleJob(jobDetail, trigger);
您还需要确保导入构建器类的静态方法,如TriggerBuilder 2.2.1中所述
import static org.quartz.TriggerBuilder.*;
import static org.quartz.JobBuilder.*;
import static org.quartz.CronScheduleBuilder.*;