spring-quartz.xml 3.0 KB
<?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:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:util="http://www.springframework.org/schema/util" xmlns:task="http://www.springframework.org/schema/task"
  xsi:schemaLocation="http://www.springframework.org/schema/beans  
  			http://www.springframework.org/schema/beans/spring-beans.xsd  
            http://www.springframework.org/schema/aop   
         	http://www.springframework.org/schema/aop/spring-aop.xsd  
         	http://www.springframework.org/schema/tx  
         	http://www.springframework.org/schema/tx/spring-tx.xsd  
        	http://www.springframework.org/schema/context  
         	http://www.springframework.org/schema/context/spring-context.xsd
       		http://www.springframework.org/schema/util
           	http://www.springframework.org/schema/util/spring-util.xsd
           	http://www.springframework.org/schema/task  
       		http://www.springframework.org/schema/task/spring-task.xsd"
       		default-lazy-init="false"> <!-- default-autowire="byName"  -->
       
	<context:property-placeholder location="classpath:application.properties" ignore-unresolvable="true" />
  
  	<bean id="jobFactory" class="com.eport.schedule.MyJobFactory"></bean>
  	<!--- 触发器的bean的设置,在这里我们设置了我们要触发的jobDetail是哪个 -->
    <bean id="messageJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
    	<property name="jobDetail">
             <bean id="messageJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
                 <property name="jobClass" value="com.eport.schedule.MessageJob" />
                 <property name="applicationContextJobDataKey" value="ctx" />
                 <property name="group" value="TEST" />
                 <property name="durability" value="true" />
             </bean>
         </property>
         <!-- <property name="jobFactory">
         	<bean class="com.eport.schedule.MyJobFactory"/>
         </property> -->
         <property name="cronExpression">
             <value>0/5 * * * * ?</value>   <!-- 0 54 9 * * ? 每天9点54分触发一次 -->
         </property>
     </bean>
 
      <!-- 管理触发器的总设置,管理我们的触发器列表,可以在bean的list中放置多个触发器    -->
     <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
         <property name="triggers">
             <list>            
                 <ref bean="messageJobTrigger" />                
             </list>
        </property>
         <property name="quartzProperties">
             <props>
                 <prop key="org.quartz.scheduler.skipUpdateCheck">true</prop>
             </props>
         </property>
         <property name="jobFactory" ref="jobFactory"></property>
     </bean>

</beans>