• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

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

·

답변을 작성해보세요.

0

csw님의 프로필

csw

질문자

2020.01.06

답변 감사합니다. 실 환경에서는 매번 빌드를 할 수 없을테니, java 로 app 실행한 후에 property 파일만 수정해서 테스트 하였습니다. 이 경우 print한 값이 바뀌어야 할 것 같은데, 변화가 없어서 문의 드렸습니다.

0

이해하신게 맞고 실제로 해당 수업 영상 6분 30초 부터 리로드가 되는 모습을 데모로 보여드렸습니다. 다시 보시면서 그대로 따라해 보세요.