Announcement Announcement Module
Collapse
No announcement yet.
ClassPathXmlApplicationContext and multiple root directories Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


    • #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.

      Comment


      • #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.

        Comment


        • #5
          Ah, I see:

          http://www.springframework.org/docs/...path-wildcards

          Thanks alot!

          Comment

          Working...
          X