Results 1 to 5 of 5

Thread: ClassPathXmlApplicationContext and multiple root directories

  1. #1
    Join Date
    Mar 2007
    Posts
    561

    Default 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?

  2. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    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).

  3. #3
    Join Date
    Mar 2007
    Posts
    561

    Default

    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.

  4. #4
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    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.

  5. #5
    Join Date
    Mar 2007
    Posts
    561

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •