Search code examples
javaspring-mvctomcatresourcebundle

What is the best approach for resource bundle in Spring MVC?


I'm building a new web app using Spring MVC 4 (under Tomcat) and I need to know what is the best approach to store the message source in my webapp.

Actually, I'm thinking to use the Spring properties file to manage all labels but I have some questions to ask:

  1. If I add a new message in my properties file, do I need to redeploy my webapp on Tomcat (restart application on Tomcat)?
  2. Could be the database driven resource the best approach for this? In this case, i could avoid to redeploy the webapp on Tomcat (because my message resources are managed in my database)...

Thank you!!


Solution

  • To answer your question yes you will have to redeploy if your messages change. Resource bundles are built and compiled once into the class files and stay the same unless you rebuild and redeploy. If you find that you need a dynamic messages that change without redeploying then it would be best to use something like a database. It's unusual however if you can't bring the application down then yes, put them in a database so you can redeploy them.