码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2020-04-27 15:10:53      阅读:81      评论:0      收藏:0      [点我收藏+]

标签:||   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>5000</value></property>
        <property name="repeatCount"><value>-1</value></property>
        <property name="repeatInterval"><value>36000000</value></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" /> <!--目标Job-->  
        </property>  
        <property name="targetMethod">  
            <value>doCreate</value> <!--目标方法-->  
        </property>  
        <property name="concurrent">  
            <value>false</value> <!--定时任务串行-->  
        </property>  
    </bean>

 

4、

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

 

5、

在CreateFileAndStuff.Java

/**
     * 开始生成
     */
    public synchronized void doCreate(){
        
        if ("yes".equals(ConfigUtil.createFileAndSuffSwitch())) {
            List<Map<String ,Object>> 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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!