Spring 설정xml - property-context.xml
Spring 설정xml - property-context.xml
쓸만한 JSP 홈페이지 만들기
이 프로젝트에서는 메세지 전부를 한 파일에 모아놓을것이다.
그를 위한 property-context.xml이다.
다국어 홈페이지를 개발할때 유용하다.
각 언어의 파일을 properties파일에 모아놓을 수 있기 때문이다.
추후 변경될 수 있는 파일이다.
spring boot에서는 yaml파일로 대체할 수 있다.
계층 성격을 가지는 변수를 properties로 사용했을 때보다 더 가독도 쉬우며 작성하기도 간편하다.
1. spring xsd 선언
2. Reader클래스와 config파일
- properties파일을 읽을 수 있는 Reader를 정의한다.
- 그 속성으로 properties파일을 정의할 config.xml 파일을 불러오도록 하고
- reloadable 속성을 true로 설정한다. 이는 ConfigurationReader에서 사용할 변수이다.
3. 자동읽기 처리
classpath:/message/error classpath:/message/message
- ReloadableResourceBundleMessageSource 를 쓰게 되면 WAS 를 재로딩하지 않아도 수정된 resource 파일들을 자동으로 읽어 들이게 할수 있다.
- 60초마다 자동으로 읽어 변화에대한 체크를 한다.
4. 헬퍼클래스 설정
- MessageSource를 사용하기 위해 헬퍼클래스Accessor 설정한다.
참고 : https://mainia.tistory.com/212
https://devks.tistory.com/42
property-context.xml 끝
from http://eongeuni.tistory.com/79 by ccl(S) rewrite - 2020-03-06 19:21:14
댓글
댓글 쓰기