spring-boot入门学习笔记(异步/定时)

异步使用方法:spring-使用注解
启动类上增加注解@EnableAsync
要增加异步运行的类,增加@Async

定时任务:
启动类上增加注解@EnableScheduling
定时任务方法,增加@Scheduled

@Scheduled(cron = “*/3 * * * * MON-FRI”)
/**
* 秒 分 时 天 月 星期几
* */3 代表三秒执行一次
* MON-FRI 周一到周五
*/

, 枚举值: 1,3 1和3
- 区间: 1-3 1到3
* 每间隔多久 */3 每3

在线生成cron表达式地址 https://cron.qqe2.com/

猜你喜欢

转载自blog.csdn.net/qq_38230472/article/details/113113161
今日推荐