Springbootタイミングタスクスケジューラ
1767 ワード
Springbootタイミングタスクスケジューラ
1.タスクスケジュールコンポーネントの作成
1.タスクスケジュールコンポーネントの作成
@Component
/**
*
*/
@EnableScheduling
@Slf4j
public class TimerConfig {
/**
* cron
*/
@Scheduled(cron = "0 0/1 * * * *")
public void redisTimer() throws Exception {
//
if (log.isInfoEnabled()) {
log.info("class : {} run start.", TimerConfig.class);
}
// , ,
RedisTimer.setTimeNow();
}
/**
* fixedRate
*/
@Scheduled(fixedRate = 1000)
public void logTimer() throws Exception {
//
log.info("now is : {}", DateTimeUtils.of(DateTimePattern.YYYY_MM_DD_HH_MM_SS));
}
}
// Springboot