package com.qxgmat.schedule; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.text.SimpleDateFormat; import java.util.Date; /** * Created by gaojie on 2017/11/20. */ @Component public class Schedule { /** * cron表达式:* * * * * *(共6位,使用空格隔开,具体如下) * cron表达式:*(秒0-59) *(分钟0-59) *(小时0-23) *(日期1-31) *(月份1-12或是JAN-DEC) *(星期1-7或是SUN-SAT) * 注意: 30 * * * * * 表示每分钟的第30秒执行,而(*斜杠30)表示每30秒执行 * * */ @Scheduled(cron="0 0 * * * *") public void refreshToken(){ // 每小时刷新快过期用户的accessToken } @Scheduled(cron="0 0 * * * *") public void refreshPrepare(){ // 每小时刷新备考统计信息 } @Scheduled(cron="0 0 0 * * *") public void autoExercisePaper(){ // 每天判断是否自动组卷 } }