quartz spring 整合例子

1. 引入quartz jar包

2.application.xml中配置代码:

 <!-- 定义远程调用service down -->
 <bean id="qzetaoGoodsInfoService"
  class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
  <property name="serviceUrl" value="${remote.appUri}/hessian/etaoGoodsInfoService-hessian" />
  <property name="serviceInterface" value="com.luolai.ec.services.fe.passport.IFeEtaoGoodsInfoService" />
 </bean>
 <!-- 定义远程调用service up -->
 <!-- 定义操作BEAN -->
 <bean id="jobtaskCreateEtaoInfo"
  class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
  <property name="targetObject">
   <ref bean="qzetaoGoodsInfoService" />
  </property>
  <property name="targetMethod">
   <value>createIncrementIndex</value>
  </property>
  
 </bean>
 <bean id="doCreateEtaoInfo" class="org.springframework.scheduling.quartz.CronTriggerBean">
  <property name="jobDetail">
   <ref bean="jobtaskCreateEtaoInfo" />
  </property>
  <property name="cronExpression">
    <!-- 每隔1小时执行一次-->
             <value>0 0 0/1 * * ?</value>
  </property>
 </bean>

真正的spring调用定时程序

<!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 -->

<bean id="scheduler" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
  <property name="triggers">
   <list>
     <ref bean="doCreateEtaoInfo" />
   </list>
  </property>
 </bean>

原文地址:https://www.cnblogs.com/doosmile/p/2595102.html