首页 > 其他 > 详细

spring定时器

时间:2014-03-08 03:12:03      阅读:520      评论:0      收藏:0      [点我收藏+]
<?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: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.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
	
	<!-- 1 引入spring定时器的支持类  同时指定作用于那个类  哪个方法  -->
	<bean id="helloWord"
		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<!--targetObject指的是触发对象所在的类
			这个类已经在spring中注册了,这里直接把bean的id拿过来用就可以了-->
		<property name="targetObject" ref="productServiceImpl" />
		<!-- targetMethod指的是触发的方法,当触发条件符合时,就会自动执行test方法 -->
		<property name="targetMethod" value="sendEmail" />
		
	</bean>
	
	
	
	<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail">
			<ref bean="helloWord" />
		</property>
		<property name="cronExpression">
			<value>0 0/2 20 * * ?</value>
		</property>
	</bean>
	

	<!--公共启动任务 3-->
	<bean id="quartzFactory"
		class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<!-- triggers属性接受一组触发器 -->
		<property name="triggers">
			<list>
				<ref local="cronTrigger" />
			</list>
		</property>
	</bean>
</beans>

spring定时器,布布扣,bubuko.com

spring定时器

原文:http://blog.csdn.net/sxj_world/article/details/20715865

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!