一次简单使用Spring+Quartz配置定时任务

2021-02-05 18:14

阅读:512

标签:||   inter   tde   null   eth   prope   tailf   bsp   java   

1、

bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">  
        property name="triggers">  
            list>  
                  ref local="createFileAndStuffTrigger"/>
            list>  
        property>  
    bean>

 

2、

bean id="createFileAndStuffTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
        property name="startDelay">value>5000value>property>
        property name="repeatCount">value>-1value>property>
        property name="repeatInterval">value>36000000value>property>
        property name="jobDetail">ref bean="createFileAndStuffTask" />property>
    bean> 

 

3、

bean id="createFileAndStuffTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">  
        property name="targetObject">  
            ref bean="jobService" />   
        property>  
        property name="targetMethod">  
            value>doCreatevalue>   
        property>  
        property name="concurrent">  
            value>falsevalue>   
        property>  
    bean>

 

4、

bean id="jobService" class="com.task.CreateFileAndStuff">bean>

 

5、

在CreateFileAndStuff.Java

/**
     * 开始生成
     */
    public synchronized void doCreate(){
        
        if ("yes".equals(ConfigUtil.createFileAndSuffSwitch())) {
            List> switchDList=this.getBusInfo();
            
            if(null==switchDList || 0==switchDList.size()) return;
            
            this.doCreateForLoopSwitch(switchDList,one_number);
        }
        
    }

 

一次简单使用Spring+Quartz配置定时任务

标签:||   inter   tde   null   eth   prope   tailf   bsp   java   

原文地址:https://www.cnblogs.com/nachdenken/p/12786733.html


评论


亲,登录后才可以留言!