我接触的quartz用法比较简单,就是每个一段时间调用一下ServiceImpl的一个方法,
其配置文件如下:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> <!-- 基础数据 begin --> <bean id="cacheUpdateSchedulJobtask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="applicationCacheService"></property> <property name="targetMethod"><value>synchDataUpdated</value></property> </bean> <bean id="simpleCacheUpdateFactory" class="org.springframework.scheduling.quartz.SimpleTriggerBean"> <property name="jobDetail" ref="cacheUpdateSchedulJobtask"></property> <property name="startDelay" value="0"></property> <property name="repeatInterval"><value>300000</value><!-- 每隔5分钟执行一次 --> </property> </bean> <bean id="startcacheUpdateSchedulJobQuertz" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="simpleCacheUpdateFactory" /> </list> </property> </bean> </beans>