Hi guys is there any good examples of changing spring properties f开发者_如何学编程iles content dynamically? I would really appreciate it if you could give me some example or link.
Thanks alot
I think you could use ReloadableResourceBundleMessageSource .It uses java.util.Properties
instances as its internal data structure for messages.
Also , as the name suggests , this class supports reloading of properties files through the cacheSeconds setting, and also through programmatically clearing the properties cache. Note that since application servers do typically cache all files loaded from the classpath, you have to put properties files outside of your classpath (WEB-INF/classes
) or it'll be cached and won't work.
References / examples / links
- http://techdive.in/spring/spring-internationalization-i18n
- http://www.jroller.com/raible/entry/spring_mvc_s_reloadableresourcebundlemessagesource
Actually, spring support ${variable} in configration file like below
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>file:${XXX}/XXX.properties</value>
<value>file:${XXX}/YYY.properties</value>
</list>
</property>
</bean>
精彩评论