spring-bootmavenmeta-inf

Spring.factories in META-INF folder not added to "target" folder after packaging jar (springboot app)


I'm trying to use EnvironmentPostProcessor in order to load some docker secrets into the application properties.

I have a META-INF folder with a spring.factories file to bind the EnvironmentPostProcessor implementation, the META-INF folder is located under main/java/META-INF.

The problem I run into is that when I use maven install / maven package, the META-INF folder is added to target/classes folder, but the spring.factories file is not there.

I want to add it as a resource to be generated, and I can't have the META-INF in the resource folder because I'm also using JAX2B which needs to generate classes in package that is available to other modules (not the resource folder)

Would really appreciate some help..


Solution

  • By Maven convention it should be main/java/resources/META-INF/spring.factories

    If you don't put it under main/java/resources maven won't be able to recognize the folder and won't move anything to the target directory....

    As for JAX2B - you should generate the source files in the target/generates-sources folder (or if its something like XMLs, target/generated-resources) these folders are also recognized by IntelliJ for example. In any case you should not generate anything under src/main, its a place for you source files not for the generated files.