Jul 20th, 2007, 03:46 PM
ClassPathXmlApplicationContext and multiple root directories
I'm using a ClassPathXmlApplicationContext and it seems that it only uses the xml-files from the first directory in the classpath.
Only the files from /foo are loaded.
Any way to get it working with multiple dirs?
Jul 23rd, 2007, 09:23 AM
If the files have diferent names they can be loaded from /foo and /bar. It they have the same name you will need to use something like a ResourcePatternResolver to locate the files before loading them with ClassPathXmlApplicationContext. Some of the Spring context utilities do this for you (e.g. the ContextLoaderListener in a web app).
Jul 23rd, 2007, 03:50 PM
Ah I see, I used "/somefilename*.properties" This seems not to work with multiple paths, right?
I looked into the source but I couldn't find the code where the files are loaded.
Jul 25th, 2007, 01:46 AM
The Strings are converted to resources and loaded in AbstractBeanDefinitionLoader. So ResourcePatternResolver is used. I think "classpath*:/somefilename.properties" works for multiple classpath entries, but not "/somefilename*.properties" (which might work in the filesystem). You can experiment with PathMatchingResourcePatternResolver to see how to interpret the results.
Jul 25th, 2007, 07:56 AM