Spring Quartz定时器源码和配置文件
配置好,直接重启tomcat,直接生效,经常用来执行一些定时任务
-
<?xml version="1.0" encoding="utf-8"?>
-
<beans xmlns=""
-
xmlns:xsi=""
-
xmlns:aop=""
-
xmlns:context=""
-
xsi:schemaLocation="
-
-
/spring-beans-3.0.xsd
-
-
/spring-aop-3.0.xsd
-
-
/spring-context-3.0.xsd">
-
<bean id="testDao" parent="baseDAO" class="com.gcccdi.opexxx.daos.impl.TestDaoHibernate" scope="prototype" />
-
<bean id="userLogDao" parent="baseDAO" class="com.gcccdi.opexxx.daos.impl.UserLogDaoHibernate" scope="prototype" />
-
-
<!-- 配置定时器 -->
-
<bean id="timingJob" class="test.SnatchWeb" />
-
<!-- 配置一个Job,方法 -->
-
<bean id="jobBean" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
-
<property name="targetObject">
-
<ref bean="timingJob"/>
-
</property>
-
<property name="targetMethod">
-
<value>updateForeignCurrency</value>
-
</property>
-
</bean>
-
<!-- 简单的触发器 -->
-
<bean id="simpleTimingJobTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
-
<property name="jobDetail">
-
<ref bean="jobBean" />
-
</property>
-
<!-- 以毫秒为单位,启动后一分钟触发 -->
-
<property name="startDelay">
-
<value>60000</value>
-
</property>
-
<!-- 每间隔一分钟触发一次 -->
-
<property name="repeatInterval">
-
<value>60000</value>
-
</property>
-
</bean>
-
<!-- Spring触发工厂 -->
-
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
-
<property name="triggers">
-
<list>
-
<ref bean="simpleTimingJobTrigger"/>
-
</list>
-
</property>
-
</bean>
-
-
</beans>
阅读(4464) | 评论(0) | 转发(0) |