Reputation: 65
Hi guys is there any good examples of changing spring properties files content dynamically? I would really appreciate it if you could give me some example or link.
Thanks alot
Upvotes: 2
Views: 4059
Reputation: 90527
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
Upvotes: 5
Reputation: 776
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>
Upvotes: -2