Ryan
Ryan

Reputation: 24043

How to automatically reload messages.properties files in Java/Spring?

I've been working on an interntaional website using Java/Spring using #springMessage() tags and message.properties files. See my recent question: In Java/Spring, how to gracefully handle missing translation values?

I want to be able to edit (overwrite) the messages.properties files and be able to see the new translations immedatiately in my browser (without restarting Tomcat).

I thought that http://commons.apache.org/proper/commons-configuration/userguide/howto_filebased.html#Automatic_Reloading would be what I need, but I'm not sure how to edit my webmvc-config.xml to use that.

Upvotes: 3

Views: 3819

Answers (1)

Ryan
Ryan

Reputation: 24043

Figured it out. It worked after I edited webmvc-config.xml:

<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>

(I just needed to add the cacheSeconds property.)

Upvotes: 7

Related Questions