public static void main(String[] args) {
//配置模式 build模式
//1.实例一个JOB
JobDetail jobDetail = JobBuilder.newJob(QuartzJob.class)
.withIdentity("myjob", "group")
//jobDataMap 在构建JobDetail时,可以将数据放入JobDataMap,
.usingJobData("jobSays", "Hello World!")
.usingJobData("myFloatValue", 3.14f)
.build();
//2.0实例一个触发器
Trigger trigger = newTrigger()
.withIdentity("trigger1", "group1")
.startNow()
.withSchedule(simpleSchedule()//simple方式配置 corn配置请自行百度
.withIntervalInSeconds(4)
.repeatForever())
.usingJobData("jobSays", "2222")
.usingJobData("myFloatValue", 3.004f)
.build();
//3.0调度器调度实例化,整合实例的job和触发器
try {
Scheduler scheduler =StdSchedulerFactory.getDefaultScheduler();
scheduler.scheduleJob(jobDetail, trigger);
//4.启动
scheduler.start();
} catch (SchedulerException e) {
e.printStackTrace();
}
}





由此可见JobExecutionContext中的JobDataMapjob的值会取
Trigger中的JobDataMapjob值。
所以Trigger中的JobDataMapjob值。会把JobDataMapjob的值覆盖
12-20 15:28