2013-08-09 2 views
1

나는 #springMessage() 태그와 message.properties 파일을 사용하여 Java/Spring을 사용하여 interntaional 웹 사이트에서 작업 해 왔습니다. 내 최근 질문보기 : In Java/Spring, how to gracefully handle missing translation values?Java/Spring에서 messages.properties 파일을 자동으로 다시로드하는 방법은 무엇입니까?

messages.properties 파일을 편집 (덮어 쓰기)하고 브라우저에서 immedatiately (Tomcat을 다시 시작하지 않고) 새 번역본을 볼 수 있기를 원합니다.

나는 http://commons.apache.org/proper/commons-configuration/userguide/howto_filebased.html#Automatic_Reloading이 내가 필요한 것이라고 생각했지만, 나는 그것을 사용하기 위해 내 webmvc-config.xml을 편집하는 방법을 모르겠다.

+0

충분하지 않을 수있는 속성 파일을 다시로드 : 내가 webmvc-config.xml 파일을 편집 한 후했다. 빈의 파일 중 하나라도 파일의 값에 의존하면 다시 만들어야합니다. 즉, 응용 프로그램 컨텍스트를 긁어내어 새로 고치고 내부의 모든 빈을 재생성합니다. 아마도 앱을 다시 시작하는 것이 가장 좋습니다. 대신 Spring이 처리하지 않는 구성 파일을 참조하는 구성 클래스를 사용할 수 있습니다. –

답변

8

알아 냈어.

<bean id="messageSource" 
    class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> 
    <property name="basename"> 
     <value>${content.path.config}/WEB-INF/messages</value> 
    </property> 
    <property name="defaultEncoding" value="UTF-8" /> 
    <property name="cacheSeconds" value="2"/> 
</bean> 

(. 난 그냥 cacheSeconds 속성을 추가하는 데 필요한)

관련 문제