<bean id="quartzJob" class="com.rd.quartz.QuartzJob"></bean>
<!-- 配置定时器详情 -->
<bean id="updateOrderStatusDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"><property name="targetObject">
<ref bean="quartzJob"/><!-- 指定任务类 -->
</property>
<property name="targetMethod">
<value>updateOrderStatus</value> <!-- 指定任务方法 -->
</property>
</bean>
<bean id="updateOrderStatusTimer" class="com.rd.quartz.InitializingCronTrigger">
<property name="jobDetail">
<ref bean="updateOrderStatusDetail"/>
</property>
<property name="cronExpression">
<value>0 0/1 * * * ?</value><!-- 0分开始 每分钟执行一次-->
</property>
</bean>
<!-- 配置启动定时器 -->
<bean id="startQuertz" lazy-init="false" autowire="no"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<!-- 必需 -->
<ref bean="updateOrderStatusTimer" />
</list>
</property>
</bean>
在web.xml中配置定时器配置文件地址和类加载监听器
<!-- 配置Spring容器 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/spring/applicationQuartz.xml
</param-value>
</context-param>
<!-- 配置Spring启动监听器 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>