SSH实现定时任务

1、两种实现方式:1 xml      2 注解

注解式:三个核心注解 (不需要额外配置文件)

类上的:@Component & @EnableScheduling

定时执行的方法上的:@Scheduled(cron="0 0/10 * * * ?")

 

XML式:applicationContext.xml中配置:

 

定时执行的方法上的:@Scheduled(cron="0 0/10 * * * ?")

 

2、cron表达式讲解

https://www.cnblogs.com/sawyerlsy/p/7208321.html

 3、定时任务一般是作为工具类放在项目中的utils包中

posted @ 2021-02-26 16:32  Caesar_the_great  阅读(1533)  评论(0编辑  收藏  举报