spring对Quartz提供的任务调度支持(简单配置)

public class ClearMeterialJob extends QuartzJobBean { 

protected void executeInternal(JobExecutionContext context) { 
//这里写定时操作的代码 
} 
} 


需在spring配置文件中做如下配置
<!-- 一下为使用Quartz调度器,清理临时资源文件 --> 
<!--定义定时任务类--> 
<bean id="clearJob" class="org.springframework.scheduling.quartz.JobDetailBean"> 
    <property name="jobClass"> 
     <value>test.ClearMeterialJob</value> 
    </property> 
   </bean> 

  
  <bean id="cronReportTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> 
    <property name="jobDetail"> 
    <ref bean ="clearJob" /> 
    </property> 
    <!--这里定义每天23点59分的时候执行一次操作--> 
    <property name="cronExpression"> 
     <value>0 59 23 * * ?</value> 
    </property> 
   </bean> 

<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> 
<property name="triggers"> 
      <list> 
          <ref local="cronReportTrigger"/> 
      </list> 
</property> 
<property name="quartzProperties"> 
      <props> 
          <prop key="org.quartz.threadPool.threadCount">5</prop> 
      </props> 
</property> 
</bean> 

你可能感兴趣的:(java,spring,quartz)