-
카테고리
-
세부 분야
백엔드
-
해결 여부
미해결
messageSource cache 질문드립니다.
20.01.05 17:35 작성 조회수 268
0
- 죄송합니다. 질문이 잘 못 된 것 같아 다시 드립니다. (원래 적었던 질문은 지웠습니다...)
setCacheSeconds 설명을 보면, 설정된 interval 로 properties를 refresh 하는 것으로 이해 했습니다.
public void setCacheSeconds(int cacheSeconds)
Set the number of seconds to cache loaded properties files.
- Default is "-1", indicating to cache forever (just like
java.util.ResourceBundle
). - A positive number will cache loaded properties files for the given number of seconds. This is essentially the interval between refresh checks. Note that a refresh attempt will first check the last-modified timestamp of the file before actually reloading it; so if files don't change, this interval can be set rather low, as refresh attempts will not actually reload.
그런데, 아래 부분에서 3초로 설정해도 application 실행 중에는 properties 파일을 변경하여도 print 되는 properties 는 변경이 없었습니다.
@Bean
MessageSource messageSource() {
var messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename("classpath:/messages");
messageSource.setDefaultEncoding("utf-8");
messageSource.setCacheSeconds(3);
return messageSource;
}
혹시 제가 잘못 이해한 부분이 있는지 알려주시면 감사하겠습니다.
답변을 작성해보세요.
답변 2