欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

spring quartz 多定时任务

程序员文章站 2022-07-13 17:51:17
...
  1.  <bean id="TaskAuto" class="cn.com.opendata.util.timer.TaskAuto">     
  2.         <property name="hastenManager">     
  3.             <ref bean="HqjcHasten_Poll"/>     
  4.         </property>     
  5.         <property name="depaUserManager">     
  6.             <ref bean="HqjcDepaUsers_Poll"/>     
  7.         </property>  
  8.     </bean>  
  9.        
  10.     <!-- 月报 -->  
  11.     <bean id="yueBaoDetail"  
  12.         class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">  
  13.         <property name="targetObject">  
  14.             <ref bean="TaskAuto" />  
  15.         </property>  
  16.         <property name="targetMethod">  
  17.             <value>yueBao</value>  
  18.         </property>  
  19.     </bean>  
  20.     <bean id="yueBaoTrigger"  
  21.         class="org.springframework.scheduling.quartz.CronTriggerBean">  
  22.         <property name="jobDetail">  
  23.             <ref bean="yueBaoDetail"/>  
  24.         </property>  
  25.         <property name="cronExpression">  
  26.             <!-- 每个月15日晚23点整 -->  
  27.             <value>0 0 23 15 * ?</value>  
  28. <!--         <value>0/10 * * * * ?</value>-->  
  29.         </property>  
  30.     </bean>  
  31.     <!-- 季报 -->  
  32.     <bean id="jiBaoDetail"  
  33.         class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">  
  34.         <property name="targetObject">  
  35.             <ref bean="TaskAuto" />  
  36.         </property>  
  37.         <property name="targetMethod">  
  38.             <value>jiBao</value>  
  39.         </property>  
  40.     </bean>  
  41.     <bean id="jiBaoTrigger"  
  42.         class="org.springframework.scheduling.quartz.CronTriggerBean">  
  43.         <property name="jobDetail">  
  44.             <ref bean="jiBaoDetail"/>  
  45.         </property>  
  46.         <property name="cronExpression">  
  47.             <!-- 每年4月15日起每隔3个月晚23点 -->  
  48.             <value>0 0 23 15 4/3 ?</value>  
  49.         </property>  
  50.     </bean>  
  51.     <!-- 春节 -->  
  52.     <bean id="chunJieDetail"  
  53.         class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">  
  54.         <property name="targetObject">  
  55.             <ref bean="TaskAuto" />  
  56.         </property>  
  57.         <property name="targetMethod">  
  58.             <value>chunJie</value>  
  59.         </property>  
  60.     </bean>  
  61.     <bean id="chunJieTrigger"  
  62.         class="org.springframework.scheduling.quartz.CronTriggerBean">  
  63.         <property name="jobDetail">  
  64.             <ref bean="chunJieDetail"/>  
  65.         </property>  
  66.         <property name="cronExpression">  
  67.             <!-- 每年3月份最后一天晚23时 -->  
  68.             <value>0 0 23 L 3 ?</value>  
  69.         </property>  
  70.     </bean>  
  71.     <!-- 十一 -->  
  72.     <bean id="shiYiDetail"  
  73.         class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">  
  74.         <property name="targetObject">  
  75.             <ref bean="TaskAuto" />  
  76.         </property>  
  77.         <property name="targetMethod">  
  78.             <value>shiYi</value>  
  79.         </property>  
  80.     </bean>  
  81.     <bean id="shiYiTrigger"  
  82.         class="org.springframework.scheduling.quartz.CronTriggerBean">  
  83.         <property name="jobDetail">  
  84.             <ref bean="shiYiDetail"/>  
  85.         </property>  
  86.         <property name="cronExpression">  
  87.             <!-- 每年10月最后一天晚23时 -->  
  88.             <value>0 0 23 L 10 ?</value>  
  89.         </property>  
  90.     </bean>  
  91.        
  92.     <!-- 任务列表 -->  
  93.     <bean  
  94.         class="org.springframework.scheduling.quartz.SchedulerFactoryBean">  
  95.         <property name="triggers">  
  96.             <list>  
  97.                 <ref local="yueBaoTrigger" /><!-- 月报 -->  
  98.                 <ref local="jiBaoTrigger"/><!-- 季报 -->  
  99. <!--             <ref local="chunJieTrigger"/> 春节 -->  
  100. <!--             <ref local="shiYiTrigger"/> 十一 -->  
  101.             </list>  
  102.         </property>  
  103.     </bean>  
  104.        
  105.     <!-- spring定时任务 结束  -->