本文最后更新于70 天前,其中的信息可能已经过时,如有错误请发送邮件到qiqin-chang@qq.com
使用步骤:
- 导入maven坐标:spring-context(已存在)
- 启动类添加注解:@EnableScheduling //开启任务调度
- 自定义定时任务类
与ServiceImpl层相似:
/**
* 定时任务
*/
@Scheduled(cron = "0/5 * * * * ?") //每隔5秒触发一次
public void execute() {
log.info("定时任务开始执行:{}",new Date());
}