Showing
1 changed file
with
0 additions
and
22 deletions
| 1 | -package com.infoloop.tianting.task; | ||
| 2 | - | ||
| 3 | -import org.springframework.scheduling.annotation.EnableScheduling; | ||
| 4 | -import org.springframework.scheduling.annotation.Scheduled; | ||
| 5 | -import org.springframework.stereotype.Component; | ||
| 6 | - | ||
| 7 | -@Component | ||
| 8 | -@EnableScheduling | ||
| 9 | -public class ScheduledTask { | ||
| 10 | - | ||
| 11 | - // 每5秒执行一次的定时任务 | ||
| 12 | -// @Scheduled(fixedRate = 5000) | ||
| 13 | -// public void task1() { | ||
| 14 | -// System.out.println("定时任务1:每5秒执行一次,当前时间:" + System.currentTimeMillis()); | ||
| 15 | -// } | ||
| 16 | - | ||
| 17 | - // 每天凌晨2点执行一次的定时任务 | ||
| 18 | - @Scheduled(cron = "0 0 2 * * *") | ||
| 19 | - public void taskForUpdateOrderStatus() { | ||
| 20 | - System.out.println("定时任务2:每天凌晨2点执行一次,当前时间:" + System.currentTimeMillis()); | ||
| 21 | - } | ||
| 22 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment