虽然quartz和Spring3+自带的task很简单,但是很多项目目前还是2.5版本,只写配置,
类要继承TimerTask
<?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:context="http://www.springframework.org/schema/context"
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.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<bean id="Card" class="com.csch.logistics.utils.SynchDB2DB" scope="prototype" />
<bean id="Record" class="com.csch.logistics.utils.SynchIcCard2IcCard" scope="prototype" />
<bean id="job1" class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean">
<property name="targetObject" ref="Card"></property>
<property name="targetMethod" value="run"></property>
</bean>
<bean id="job2" class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean">
<property name="targetObject" ref="Record"></property>
<property name="targetMethod" value="run"></property>
</bean>
<bean id="syncCard" class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="timerTask" ref="job1"></property>
<property name="period" value="30000"></property>
<property name="delay" value="3000"></property>
</bean>
<bean id="syncRecord" class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="timerTask" ref="job2"></property>
<property name="period" value="20000"></property>
<property name="delay" value="5000"></property>
</bean>
<bean id="timerFactoryBean" class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref bean="syncCard" />
<ref bean="syncRecord" />
</list>
</property>
</bean>
</beans>
Comments | NOTHING