-
Jul 20th, 2007, 03:46 PM
#1
ClassPathXmlApplicationContext and multiple root directories
Hi,
I'm using a ClassPathXmlApplicationContext and it seems that it only uses the xml-files from the first directory in the classpath.
E.g.:
-classpath "/foo;/bar"
Only the files from /foo are loaded.
Why?
Any way to get it working with multiple dirs?
-
Jul 23rd, 2007, 09:23 AM
#2
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
#3
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
#4
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
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules