quertz定时器



<?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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" >

    <!--哪个类的什么方法需要定时执行?-->
    <bean id="mybean" class="com.uplooking.club.base.util.JobUtil"/>
    <bean id="simpleJobDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject" ref="mybean"/>
        <property name="targetMethod" value="creatHTML"/>

    </bean>

    <!--什么时候执行?-->
    <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
        <property name="jobDetail" ref="simpleJobDetail"/>
        <property name="cronExpression" value="0/5 * * ? * *"/>
    </bean>

    <!--统一管理多个定时器-->
    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="jobDetails">
            <list>
                <ref bean="simpleJobDetail"/>
            </list>
        </property>

        <property name="triggers">
            <list>
                <ref bean="cronTrigger"/>
            </list>
        </property>

    </bean>

</beans>