Spring定时任务配值

quartz-2.2.1.jar、quartz-examples-2.2.1.jar、quartz-jobs-2.2.1.jar

spring3.2.1

 <bean id="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
	     <!-- 自动启动 -->  
        <!--<property name="autoStartup">  
            <value>true</value>  
        </property> -->
        <!--QuartzScheduler 延时启动 value=60  为60钞,/秒,应用启动后 QuartzScheduler 再启动--> <!--延时启动 延时60钞--> <property name="startupDelay" value="60" />
        <property name="startupDelay" value="60" />  
		<property name="triggers">
			<list>
				<ref bean="deSendTrigger" />
			</list>
		</property>
	</bean>

	 <bean id="deSendTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
		<property name="jobDetail">
			<ref bean="deSendJobDetail" />
		</property>
		<property name="cronExpression">
			<value>0 0/1 * * * ?</value>
		</property>
	</bean>

	<bean id="deSendJobDetail"
		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<property name="targetObject">
			<ref bean="CardReSendTask" />
		</property>
		<property name="targetMethod">
			<value>riveLogData</value>
		</property>
	</bean>

	<bean id="CardReSendTask" class="com..task.LogCacheRiveTask">
	</bean>  

 

package com.task;

import java.util.Date;

public class LogCacheRiveTask {
	public void riveLogData(){
		System.out.println("调用成功"+new Date());
	}
}

 

你可能感兴趣的:(spring)