這篇文章將為大家詳細講解有關(guān)SpringBoot定時任務(wù)如何在Java中使用,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。
一、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()); } }