xml 만들 때 프로젝트 내 지정된 xml 파일명 양식에 맞춰서 만든 후 하단 내용을 입력하여 저장.
1
2
3
4
5
6
7
8
9
|
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
<!-- 스케줄러 설정 -->
<task:annotation-driven/>
</beans>
|
cs |
<task:annotation-driven/>
이 친구만 있으면 어노테이션으로 모든걸 해결할 수 있다.
그래서 아래처럼 진행한 후 크론식 표기법 사용함.
1
2
3
4
5
6
7
8
9
10
11
|
@Component
public class SmsScheduler {
@Scheduled(cron = "0 0 5 * * ?") // 매일 오전 5시에 실행
public void smsTokenRequest() throws IOException {
// 문자 발송을 위한 토큰 요청 리퀘스트
}
}
|
cs |
끝
'개발공부 > Java' 카테고리의 다른 글
자료구조 큐(QUEUE) (0) | 2022.02.10 |
---|---|
Spring MVC에 웹소켓 집어넣기 3 (0) | 2021.07.31 |
Spring MVC에 웹소켓 집어넣기 2 (0) | 2021.07.29 |
Spring MVC에 웹소켓 집어넣기 1 (0) | 2021.07.15 |
Spring MVC (0) | 2021.07.15 |
댓글