To create application context, you must specify an XML Spring configuration file name. For example:
classpath*:/META-INF/spring/myapplicationconfig.xml
However, when there is more than one XML config file, it is tedious to have to specify the file names one by one:
classpath*:/META-INF/spring/conf*.xml
This article provides information on obtaining the file name and path of the XML configuration files used to initialize beans during ApplicationContext creation. The first step you may take is to is extend an application context and override the getConfigResources.
MyClassPathXmlApplicationContext extends ClassPathXmlApplicationContext { @Override protected Resource[] getConfigResources() { return super.getConfigResources(); }
On your application code, use the class above to getConfigResources. See the sample below:
MyClassPathXmlApplicationContext ctx= new MyClassPathXmlApplicationContext(); ctx.setAllowBeanDefinitionOverriding(false); ctx.setConfigLocation("classpath*:/META-INF/spring/conf*.xml"); ctx.afterPropertiesSet(); Resource r[]= ctx.getConfigResources();
Now checking Resource r[]= ctx.getConfigResources() reveals a NULL value. Discussed here are workaround on getting the actual list instead of NULL.