Programming-[Backend]/SpringBoot

[TIL][링크] messageSource application.yml 설정 옵션

컴퓨터 탐험가 찰리 2021. 12. 7. 15:41
728x90
반응형

 

지식

 

MessageSource와 관련된 설정들을 application.yml 파일에 작성할 수 있습니다. ( 참고 )

 

 key 기본값   설명
 spring.messages.always-use-message-format  false  MessasgeFormat을 전체 메시지에 적용할 것인지 여부
 spring.messages.basename  messages
 message 파일을 여러개 사용할 경우 콤마로 구분해서 여러개의 basename을 설정할 수 있다.
 spring.messages.cache-duration    캐시 주기 설정, 기본 값 forever
 spring.messages.encoding  UTF-8  인코딩 방식
 spring.messages.fallback-to-system-locale  true  감지된 locale에 대한 파일이 없는 경우,
  • 설정값 true : system locale 사용
  • 설정값 false : messages.properties 파일을 사용
 spring.messages.use-code-as-default-message  false  메시지를 찾지 못했을 때, 예외 처리 대신 메시지 코드를 그대로 반환

 

 


경험

 

실서버에는 @NotNull에 대한 message가 한국어로 나오지만, 테스트 서버에서는 message가 영어로 나와서 문제가 됬다.

 

회사 동료분께서 테스트 서버에서 fallback-to-system-locale 설정이 true로 되어있기 때문에 기본 locale인 영어로 적용된 것이 아닌가 추론하셨지만, 실제 적용 시 올바르게 해결이 되지 않았다.

 

이전 버전의 실서버 환경설정 파일을 보고 다시 해결해보기로 했다.

 


1) victolee님 블로그

https://victorydntmd.tistory.com/340

 

 

2) 회사 동료 개발자 kny 님 감사합니다.

728x90
반응형