【原创】Spring中配置任务调度器,任务随系统启动后一定时间内启动

mxcsdn 2010-07-27

<!-- 服务 -->
	<bean id="datagrabImpl" class="com.gflex.datacollect.datagrab.impl.DatagrabImpl"></bean>
	<!--任务 -->
	<bean id="timerGrab" class="com.gflex.datacollect.datagrab.TimerGrab">
		<property name="datagrabService" ref="datagrabService"></property>
	</bean>
	<!-- 任务调度器, -->
	<bean id="scheduledTimerTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
		<!-- 指定执行哪个任务 -->
		<property name="timerTask" ref="timerGrab"></property>
		<!-- 应用程序启动多久后(1.5分钟后),执行任务 -->
		<property name="delay" value="65000"></property>
	</bean>
	<!-- 启动定时器,Spring的TimerFactoryBean负责启动定时任务 -->
	<bean id="timerFactoryBean" class="org.springframework.scheduling.timer.TimerFactoryBean">
		<property name="scheduledTimerTasks">
			<list>
				<ref bean="scheduledTimerTask"/>
			</list>
		</property>
	</bean>

相关推荐

kyle00 / 0评论 2020-05-07
zhangdy0 / 0评论 2020-05-01
melonjj / 0评论 2020-02-18