Spring定时任务调度

public class PayJob extends QuartzJobBean {

		@Override
		protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
			System.out.println("PayJob开始执行。。。。。。");
		}
	}
	
	public class PunchJob extends QuartzJobBean {

		@Override
		protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
			System.out.println("PunchJob开始执行。。。。。。");
		}
	}


	<!-- 支付的Job作业类 -->
	<bean id="payJobDetailBean" class="org.springframework.scheduling.quartz.JobDetailBean">
		<property name="jobClass" value="com.iteye.schedule.PayJob"></property>
	</bean>
	
	<!-- 打卡的Job作业类 -->
	<bean id="punchJobDetailBean" class="org.springframework.scheduling.quartz.JobDetailBean">
		<property name="jobClass" value="com.iteye.schedule.PunchJob"></property>
	</bean>
	
	<!-- 支付的定时调度器 -->
	<bean id="payCronTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="payJobDetailBean"></property>
		<!-- 每分钟执行一次 -->
		<property name="cronExpression" value="0 0/1 * * * ?"></property>
	</bean>
	
	<!-- 打卡的定时调度器 -->
	<bean id="punchCronTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="punchJobDetailBean"></property>
		<!-- 每天的16:38:00执行一次 -->
		<property name="cronExpression" value="0 38 16 * * ?"></property>
	</bean>
	
	<!-- 总调度器 -->
	<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="triggers">
			<list>
				<ref local="payCronTriggerBean"></ref>
				<ref local="punchCronTriggerBean"></ref>
			</list>
		</property>
	</bean>

你可能感兴趣的:(spring)