久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

Spring+Quartz配置定時任務實現代碼

瀏覽:39日期:2023-09-07 14:23:30

作為一個優秀的開源調度框架,Quartz 具有以下特點:

強大的調度功能,例如支持豐富多樣的調度方法,可以滿足各種常規及特殊需求;

靈活的應用方式,例如支持任務和調度的多種組合方式,支持調度數據的多種存儲方式;

分布式和集群能力,Terracotta 收購后在原來功能基礎上作了進一步提升。

另外,作為 Spring 默認的調度框架,Quartz 很容易與 Spring 集成實現靈活可配置的調度功能。

代碼如下

1、

<bean class='org.springframework.scheduling.quartz.SchedulerFactoryBean'> <property name='triggers'> <list> <ref local='createFileAndStuffTrigger'/> </list> </property> </bean>

2、

<bean 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 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 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
相關文章:
主站蜘蛛池模板: 秭归县| 樟树市| 太仓市| 安溪县| 义乌市| 莱芜市| 旺苍县| 连州市| 区。| 武安市| 长武县| 巫山县| 恩施市| 饶阳县| 通渭县| 宁国市| 乌海市| 梧州市| 怀仁县| 嘉兴市| 弥渡县| 无锡市| 米易县| 建水县| 鹿邑县| 万山特区| 阳原县| 垣曲县| 抚顺县| 锡林浩特市| 义马市| 贵州省| 双桥区| 喀喇| 临西县| 三原县| 汝南县| 滦平县| 灵丘县| 都江堰市| 玉林市|