Is there a way to automatically reload Spring resource file? I want to find out a simple way to change my configuration xml in runtime. Xml file is out of classpath folder.
Any ideas?
thx:)
If you meant that you want to avoid redeploying your server to change your xml configuration, you can check JRebel http://zeroturnaround.com/jrebel/.
If it is the app contest you want to refresh, use ConfigurableApplicationContext.refresh() or more specifically for the web environment , AbstractRefreshableWebApplicationContext . You could look this up using the context:property-placeholder .
Create your own extension to the ResourceBundle interface and use that to look up your strings instead of Spring. This way, you can control things like reloading.
Yes.
Spring provides ReloadableResourceBundleMessageSource that can reload the properties file through the cacheSeconds setting.It support the properties files in the format of *.properties
and the XML format used by Properties.loadFromXML().
If your xml file is in other formats , you have to make your own resource loader by extending ReloadableResourceBundleMessageSource , and implement your logic to parse the XML file by overridding its loadProperties(Resource resource, String filename) .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With