spring定时器


//spring 定时器在application.xml中配置


<bean id="scheduledTask1" class="org.springframework.scheduling.timer.ScheduledTimerTask">
<!-- wait 10 seconds before starting repeated execution -->
<!-- run every 180 seconds -->
<property name="delay" value="10000" />
<property name="period" value="20000" />
<property name="timerTask" ref="TimeTaskDqy" />
</bean>

//在类中注入service

<bean id="TimeTaskDqy" class="com.aisino.fpdqy.timetask.TimeTaskDqy" >
   <property name="fpdqyManageService" ref="fpdqyManageService"></property>
</bean>
<bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref bean="scheduledTask1" />
</list>
</property>
</bean>

你可能感兴趣的:(spring)