Kotlin 기반 Spring 에서 스케줄 설정 하는 법을 알아봅시다.
먼저 메인 클래스에 스케줄을 활성화 합니다.
@EnableWebMvc
@EnableScheduling // 여기 선언
@SpringBootApplication( exclude= [
DataSourceAutoConfiguration::class, DataSourceTransactionManagerAutoConfiguration::class
])
class ServerApplication
그리고 사용할 메서드 위에 아래와 같이 선언한다.
@Scheduled(cron = "0 * * * * *")
@RequestMapping(value = ["/SendMatchStart"], method = [RequestMethod.POST])
fun action(request: HttpServletRequest): ResponseEntity<Any> {
//region == CommonParam ==
//endregion
//
return ApiResult.successResponse("OK")
}
와 같이 Scheduled에 Linux 크론과 동일하게 설정한다.
해당 크론 옵션은 아래와 같습니다.
끝
[Kotlin] 스케줄러에 쓰레드 적용하기 (0) | 2023.03.23 |
---|---|
[Kotlin] Switch 문 대신에 When으로 조건문 사용하기 (0) | 2023.03.07 |
댓글 영역