Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically refresh the spring mvc resource bundle

ResourceBundleMessageSource messages are configured in Spring's configuration file as

<bean id="messageSource"
  class="org.springframework.context.support.ResourceBundleMessageSource"
  p:basenames="WEB-INF/strings/appstrings" />

Whenever I changed any message in that properties file I have to restart server.

I want to read these updated messages programatically in my application without restarting server.

How can I read these messages programatically in one of my @Controller while running application.

like image 898
Muhammad Imran Tariq Avatar asked Sep 03 '25 16:09

Muhammad Imran Tariq


1 Answers

There is a ReloadableResourceBundleMessageSource ( http://static.springsource.org/spring/docs/3.2.x/javadoc-api/org/springframework/context/support/ReloadableResourceBundleMessageSource.html ) in spring that should do what you want.

You can find more info here on stackoverflow:

  • How to Inject Spring ReloadableResourceBundleMessageSource
  • How to Inject Spring ReloadableResourceBundleMessageSource
like image 81
Dirk Lachowski Avatar answered Sep 05 '25 06:09

Dirk Lachowski