Spring配置Quartz定时任务

1.首先要编写一个任务类,定时需要干的事情,如下所示:

任务类

2.写配置文件ApplicationContext.xml文件:

ApplicationContext.xml文件配置

<description>Quartz的配置description>

    
    <bean id="mailJob" class="com.dml.controller.Job">bean>

    
    <bean id="methodInvokingJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        
        <property name="targetObject" ref="mailJob">property>
        
        <property name="targetMethod" value="job">property>
    bean>

    
    <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
        <property name="jobDetail" ref="methodInvokingJob">property>
        
        <property name="cronExpression" value="0/10 * * * * ? *">property>
    bean>

    
    <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        
        <property name="triggers" >
            <list>
                <ref bean="cronTrigger">ref>
            list>
        property>
    bean>
原文链接:加载失败,请重新获取