1.配置文件 sys_config.properties:
#定义每天晚上23:00-24:00隔5分钟调用机构中心webservice
deflocExpression=0 0/5 23 * * ?
2.定时器的配置文件 applicationContext-quartz.xml
<!-- 定时器管理BEAN -->
<bean id="startQuertz" lazy-init="false"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="deflocTimeTrigger" />
</list>
</property>
</bean>
<!-- 定义触发的时间 -->
<bean id="deflocTimeTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="deflocTimeTarget" />
</property>
<!-- cron表达式 -->
<property name="cronExpression">
<value>${deflocExpression}</value>
</property>
</bean>
<!-- 测试定时器触发-要触发的类和方法 -->
<bean id="deflocTimeTarget"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- 该调用的类 -->
<property name="targetObject">
<ref bean="defLocDownloadFws" />
</property>
<!-- 该调用的方法 -->
<property name="targetMethod">
<value>doJob</value>
</property>
<property name="concurrent" value="false" />
</bean></beans>
3.配置文件 applicationContext-common.xml 读${deflocExpression}
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:sys_config.properties</value>
</list>
</property>
</bean>
4.applicationContext-service-dms.xml注入要实现的类
<bean id="defLocDownloadFws" class="com.jd.wms.mw.acm.service.impl.DefLocDownloadFwsImpl">
<property name="dmsToTmsWebService" ref="dmsToTmsWebService"></property>
</bean>
基本配置完成,实现的功能为每天23:00-24:00每隔5分钟会调用DefLocDownloadFwsImp类中的doJob方法。