Asynchronous usage: spring-use annotations
, add annotations @EnableAsync
to the startup class. To add asynchronous running classes, add @Async
Timed task:
add annotation @EnableScheduling
timed task method to start class , add @Scheduled
@Scheduled(cron = "*/3 * * * * MON-FRI")
/**
* Seconds, minutes, hours, days, months and days of the week
* */3 means to execute once in three seconds
* MON-FRI Monday to Friday
*/
, Enumeration value: 1, 3 1 and 3
-interval: 1-3 1 to 3
* how long every interval */3 every 3
Generate cron expression address online https://cron.qqe2.com/