如何传递对象类型的数据
如何传递对象类型的数据
如何传递对象类型的数据
2018-09-25
public TriggerBuilder<T> usingJobData(JobDataMap newJobDataMap)
trigger的usingJobData有这个方法;
User user = new User(); user.setAge(12); user.setName("Jack"); JobDataMap dataMap = new JobDataMap(); dataMap.put("user",user);SimpleTrigger trigger = TriggerBuilder.newTrigger() .withIdentity("myTrigger", "group1") .usingJobData(dataMap) .startAt(date) .endAt(endDate) .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(2).withRepeatCount(3)) .build();
Trigger currentTrigger = jobExecutionContext.getTrigger(); currentTrigger.getStartTime(); currentTrigger.getEndTime(); JobDataMap jobDataMap = currentTrigger.getJobDataMap(); System.out.println("user is:" + jobDataMap.get("user")); User user = (User) jobDataMap.get("user"); System.out.println(user.getAge());
举报