In my Spring MVC controller, I use code like below to retrieve the config value.
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(propFileName); if(null != inputStream) { prop.load(inputStream); } else { throw new FileNotFoundException("property file not found in the classpath"); } a = prop.getProperty("a"); b = prop.getProperty("b");
And then I packaged the project with "mvn clean package" and deployed the war into Tomcat's webapps folder.
However, with this approach, my config.properties is packaged into the war and it is hard to change.
So would some one please provide a way to solve this problem? Can I use spring to read external config file? Please note that I need to read the config file every time the controller method is called instead of loading it when spring starts. Thanks!
Java EEJavaJava App ServersApache Web ServerApplication Servers
Thanks, gurpsbassi. Basically what I need is probably deploying the war and config file separately and letting the war be able to find the config file. So When tomcat is running, I can change the config file so that different response may be returned due to the change of the config file while tomcat doesn't need to be restarted.
gurpsbassi
You may still need to restart tomcat if the external config changes.