railway-quartz.xml 1.53 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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="checkIsLaidOffTask" class="com.xiniunet.quartz.CheckIsLaidOffQuartz"/>
    <!-- 定义任务类和要执行的方法 -->
    <bean id="checkIsLaidOff" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <!--false:上个任务执行完毕后, 再开启新的人去-->
        <property name="concurrent" value="false"/>
        <!--执行对象-->
        <property name="targetObject" ref="checkIsLaidOffTask"/>
        <!--执行方法-->
        <property name="targetMethod" value="execute"/>
    </bean>

    <bean id="checkIsLaidOffTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
        <property name="jobDetail">
            <ref bean="checkIsLaidOff"/>
        </property>
        <!-- 关键在配置此表达式 每1分钟执行 -->
        <property name="cronExpression">
            <value>0 0/1 * * * ?</value>
        </property>
    </bean>


    <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="checkIsLaidOffTrigger"></ref>

                <!--<ref bean="tmallTestTrigger"></ref>-->
            </list>
        </property>
    </bean>
</beans>