How do I move my spring xml configuration outside of my java web application?
I'd like to store my spring.xml outside of my web application so I don't have to create a new build of my application to change the configuration.
What is the best way to do this?
As Rod Johnson explains it in this thread:
You can use the
classpath:
prefix to load from the classpath, with the normal Spring listener or startup servlet. This is made possible by Spring's Resource abstraction. You can freely mix and match resources fromWEB-INF
and classpath.
So, put the configuration files somewhere in the classpath outside the webapp and declare the following in the web.xml
:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springContext*.xml</param-value>
</context-param>
I think that relying on the classpath is more portable than using an absolute file path.
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