在需要設定定時的位置加@scheduled 註解
cron的時間設定表示式@scheduled(cron = "*/60 * * * * ?")
public void deal1()
@bean
public resttemplate resttemplate()
}
一般有6個,也可能有7個
時段可用值
*號可用於所有字段,在分這個字段表示每分鐘。
?用在 日和周 字段,用來表示不明確的值
,指定個數, 用來在周字段中隔開
/表示增加服務 比如 0/15 以15的值增加
l 用在日和周 表示最後
w用在日字段 表示最近
lw聯合表示這個月最後一天
SpringBoot 定時任務
第一步 在啟動類中加入如下註解 enablescheduling public class public static void main string args 注意 enablescheduling必須加,否則無法開啟定時任務 第二步 建立定時任務 component public class ...
Spring boot定時任務
最近做專案,需要使用定時任務,半個小時去更新redis資料,於是便學習了一下經驗。希望可以幫到你們。定時任務可使用三種 created by fx on 2017 9 4.component allargsconstructor public class featuredatatask 實現乙個任務...
Spring boot 定時任務
1.在啟動類上加 enablescheduling註解 package com.example.demo import org.springframework.scheduling.annotation.enablescheduling enablescheduling public static ...