I have a web application with mutiple Spring configuration files. These files are loaded using “contextConfigLocation” in web.xml. Like this:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:META-INF/*beans.xml
</param-value>
</context-param>
Everything works as desired.
Now I am having to write a command line application that must load the same files as the web application. Currently I am using ClassPathXmlApplicationContext and manually specifying each configuration file name. But sooner or later somebody is going to add another file and expect it to be read by the CLI, just like the web app. Currently that will not happen because each file is explicitly specified in my CLI. So I need my CLI to load configuration files just like the web app i.e. load all configuration files that match a pattern. Is there a way to do this using ClassPathXmlApplicationContext or any other way?
I think you can do this using ClassPathXmlApplicationContext, This will load any context file that is in class path ending with name Beans