Can I have the META-INF folder into src/main/resources of a Spring command line application?

18,140

This batch works fine but I have some doubt: can this place considered the correct place where to put the applicationContext.xml file ?

Yes, this is fine. Here is a Spring Boot example that is doing precisely this.

META-INF is intended to contain the MANIFEST.MF file and the services subdirectory related to the ServiceLoader class, but other frameworks, including Spring, use it as well.

References:

http://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#The_META-INF_directory

http://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html

Share:
18,140
AndreaNobili
Author by

AndreaNobili

Updated on June 22, 2022

Comments

  • AndreaNobili
    AndreaNobili almost 2 years

    I am working on a batch aplication implemented using Spring.

    In this application I found the following structure:

    BATCH PROJECT
          |
          |
          |------> src/main/java (containing the packages)
          |
          |------> src/main/resources
                          |
                          |----------> META-INF
                                          |
                                          |--------> applicationContext.xml (Spring configuration file)
    

    So, as you can see in the previous schema, into the src/main/resources I found the META-INF folder that contain the applicationContext.xml file that contains the Spring configuration (the beans definition).

    This batch works fine but I have some doubt: can this place considered the correct place where to put the applicationContext.xml file ?

    I always see the META-INF directory into web application (and not batch application as this) into the following folder that I don't have in this project (because it is not a web application):

    webapp
    |
    |_src
    |
    |_WebContent
      |
      |__WEB-INF
      |
      |__META-INF
    

    Is it correct or can I do better?

  • Arman
    Arman about 3 years
    Unfortunately the github link is dead. Do you have a similar example?