配置好,直接重启tomcat,直接生效,经常用来执行一些定时任务
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns=".springframework.org/schema/beans"
xmlns:xsi=".w3.org/2001/XMLSchema-instance"
xmlns:aop=".springframework.org/schema/aop"
xmlns:context=".springframework.org/schema/context"
xsi:schemaLocation="
.springframework.org/schema/beans
.springframework.org/schema/beans/spring-beans-3.0.xsd
.springframework.org/schema/aop
.springframework.org/schema/aop/spring-aop-3.0.xsd
.springframework.org/schema/context
.springframework.org/schema/context/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>