spring触发器任务配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<!--配置触发器任务-->
<!-- 配置需要定时的bean类 -->
 <bean id="startWorkJob" class="com.sarnath.epc.common.StartWorkJob"></bean>
 
    <!-- 配置任务的具体类和方法 -->
 <bean id="startWorkTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
  <!-- 要调用的bean -->
  <property name="targetObject" ref="startWorkJob"></property> 
  <!-- 要调用的Method -->
  <property name="targetMethod" value="startWork"></property>
  <!-- 是否并发,false表示 如果发生错误也不影响下一次的调用 -->
  <property name="concurrent" value="false"></property>
 </bean>
 
 <!-- 配置一个触发器 -->
 <bean id="startWorkTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
  <property name="jobDetail" ref="startWorkTask"></property>
  <property name="cronExpression" value="0 25 15 * * ?"></property> <!--时间表达式-->
 </bean>
  
 <!-- 总调度,用于启动定时器 -->
 <bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
  <property name="triggers" >
   <list>
    <ref bean="startWorkTrigger"/>
   </list>
  </property>
 </bean>
	

</beans>

你可能感兴趣的:(spring)