spring定时器

来源:互联网 发布:mac excel快捷键大全 编辑:程序博客网 时间:2024/06/08 16:32
<?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.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsdhttp://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>

0 0
原创粉丝点击