第一種通過具體時間定時 ,執(zhí)行一次
<bean id="ImportTask" class="site.beans.task.ImportTimer" >
</bean> <bean id="ImportDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject"><ref bean="ImportTask"/></property> <property name="targetMethod"><value>importNews</value></property> <property name="concurrent"><value>false</value></property> </bean> <bean id="ImportTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail"> <ref bean="ImportDetail"/> </property> <property name="cronExpression">//通過具體的時間定時 <value>0 59 15 * * ?</value> </property> </bean> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref local="importTrigger"/> </list> </property> </bean> 第二種方式 通過定時多長時間執(zhí)行一次 替換上面黑體部分,關(guān)鍵是標紅的地方
<bean id="importTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail"> <ref bean="ImportDetail"/> </property> <property name="startDelay"> <value>600000</value> </property> <property name="repeatInterval"> <value>600000</value> </property> </bean> |
|