1 <bean id="kintaiAdditionalCreating" class="com.kng.timevalue.kintaiAdditional.KintaiAdditionalCreating" /> 2 第一行是<!-- 要调用的工作类 -->
第3-11行<!-- 指定任务Bean的实现类 --><!-- 为任务Bean注入属性 -->
3 <bean name="kintaiJob" class="org.springframework.scheduling.quartz.JobDetailBean"> 4 <property name="jobClass" value="com.kng.timevalue.kintaiAdditional.KintaiJob" /> 5 <!-- 指定任务Bean的实现类 --> 6 <property name="jobDataAsMap"><!-- 为任务Bean注入属性 --> 7 <map> 8 <entry key="kintaiCreating" value-ref="kintaiAdditionalCreating" /> 9 </map> 10 </property> 11 </bean> 12 第13-16行<!-- 定义触发时间 --> 13 <bean id="kintaiCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> 14 <property name="jobDetail" ref="kintaiJob" /> 15 <property name="cronExpression" value="0 02 17 * * ? *" /> 16 </bean> 17 第18-30行定义管理的 18 <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> 19 <property name="jobDetails"> 20 <list> 21 <ref bean="kintaiJob" /> 22 </list> 23 </property> 24 25 <property name="triggers"> 26 <list> 27 <ref bean="kintaiCronTrigger" /> 28 </list> 29 </property> 30 </bean>
1 public class KintaiJob extends QuartzJobBean { 2 3 @Autowired 4 private KintaiAdditionalCreating kintaiCreating; 5 6 7 8 /** 9 * @param kintaiCreating the kintaiCreating to set 10 */ 11 public void setKintaiCreating(KintaiAdditionalCreating kintaiCreating) { 12 this.kintaiCreating = kintaiCreating; 13 } 14 15 16 17 protected void executeInternal(JobExecutionContext context) 18 throws JobExecutionException { 19 kintaiCreating.addKintai(); 20 } 21 22 }
第二段代码是编写Job类PunchJob(该类必须继承QuartzJobBean)
这个类KintaiAdditionalCreating 里写要实现的逻辑