반응형
- application.yml ( application.properties ) 파일
my-host-id: xxx.xxx.xxxx
schedule:
/* 10분 간격으로 03분, 13분, 23분, 33분, 43분, 53분 실행 */
TestBatch: 0 3/10 * * * *
-----------------------------------------------------------------
my-host-id=xxx.xxx.xxxx
schedule.TestBatch=0 3/10 * * * *
- 속성 값을 사용하는 class
@Slf4j
@RequiredArgsConstructor
@Component
public class TestBatch{
@Value("${my-host-id}")
private String hostId;
@Scheduled(cron="${schedule.TestBatch}")
public void scheduled(){
...
}
application.properties 또는 application.yml 파일에 원하는 값을 지정한 다음
사용할 때는 "${ properties 이름 }" 으로 사용한다.
반응형
'스프링' 카테고리의 다른 글
@Controller 와 @RestContoller (@ResponseBody) (0) | 2022.04.12 |
---|---|
[Spring] 스프링부트 스케줄러 사용하기 (0) | 2022.03.29 |
스프링부트에서 JSP 로 화면 보여주기 (0) | 2022.02.17 |
스프링 시큐리티 + Ajax post → 403 에러 (0) | 2022.01.29 |
WebSecurityConfigurerAdapter의 configure() 오버라이딩 (0) | 2022.01.27 |