xsi:schemaLocation="http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd">
<!-- CRON 스케줄링 -->
<task:annotation-driven scheduler="scheduler"/>
<task:scheduler id="scheduler" pool-size="10"/>
<context:component-scan base-package="com.restapi.Scheduler" />
package com.diquest.Scheduler;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Component
public class SchedulerService {
//크론탭 = 초 분 시 일 월 요일
// @Scheduled(cron="0 10 16 * * *")
@Scheduled(cron="0/5 1* * * * *")
public synchronized void TestScheduler() throws Exception{
System.out.println("cron 테스트 : 5초에 1번씩 console 찍기");
}
}
<task:scheduled-tasks>
<!-- 5초에 1번씩 --> <task:scheduled ref="SchedulerService" method="TestScheduler" cron="0/5 * * * * ?"/>
</task:scheduled-tasks>
https://crontab.guru/#0_0_*_*_*
https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=rlatmdtn81&logNo=220095397512