SpringBoot regular tasks Scheduled

We sometimes use in the development of the scheduled task, this time using Scheduled annotations can quickly achieve our needs

Add annotations in the class we need regular implementation of the

//使用cron属性可按照指定时间执行,本例指的是每10分钟执行一次;
@Scheduled(cron = “0 0/10 * * * ?”) 

Then add @EnableScheduling notes on startup class.

@EnableScheduling notes, its role is found comment @Scheduled task by the background. Without it will not be able to perform regular tasks.

There are other ways, your own Baidu

Guess you like

Origin blog.csdn.net/rui15111/article/details/80972854