十年網(wǎng)站開發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
這篇文章將為大家詳細(xì)講解有關(guān)SpringBoot定時(shí)任務(wù)如何在Java中使用,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。
一、SpringBoot使用Schedule
核心代碼:
@Component public class ScheduleTask { private Logger logger = LoggerFactory.getLogger(ScheduleTask.class); @Scheduled(cron = "0/1 * * * * ? ") public void one() { logger.info("one:" + new Date()); } @Scheduled(cron = "0/1 * * * * ? ") public void two() { logger.info("two:" + new Date()); } @Scheduled(cron = "0/1 * * * * ? ") public void three() { logger.info("three:" + new Date()); } }