Spring中添加計時器的時候根據(jù)業(yè)務(wù)需求可能會需要動態(tài)處理觸發(fā)時間;
我們提供的服務(wù)有:成都網(wǎng)站建設(shè)、做網(wǎng)站、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、耿馬ssl等。為上千余家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的耿馬網(wǎng)站制作公司import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.Trigger; import org.springframework.scheduling.TriggerContext; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.SchedulingConfigurer; import org.springframework.scheduling.config.ScheduledTaskRegistrar; import org.springframework.scheduling.support.CronTrigger; import org.springframework.stereotype.Component; import java.util.Date; @Component @EnableScheduling public class SchedulerTest implements SchedulingConfigurer { private final static Logger logger = LoggerFactory.getLogger(SchedulerTest.class); public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { // 注冊計時任務(wù)到Scheduling接口 scheduledTaskRegistrar.addTriggerTask(new Runnable() { public void run() { logger.info("task job is running..."); } }, new Trigger() { public Date nextExecutionTime(TriggerContext triggerContext) { CronTrigger cronTrigger = new CronTrigger("時間表達(dá)式"); Date nextExec = cronTrigger.nextExecutionTime(triggerContext); return nextExec; } }); } }
分享題目:Spring動態(tài)配置計時器觸發(fā)時間的實例代碼-創(chuàng)新互聯(lián)
文章路徑:http://bm7419.com/article12/didpdc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、網(wǎng)站收錄、網(wǎng)站導(dǎo)航、微信公眾號、建站公司、營銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容