Spring auto-config class is missing from META-INF / spring.factories files

I am trying to build a spring based application, but after build I get an exception when initializing the spring -> context No auto configuration classes found in META-INF/spring.factories

. I am actively working with spark in my application and I am forced to use maven-assembly-plugin

to package my can (otherwise I cannot start the spark job).

sample of my main class:

@SpringBootApplication
@EnableAutoConfiguration
public class MyMainClass {
    public static void main(String[] args) {

        ConfigurableApplicationContext ctx = new SpringApplicationBuilder(MyMainClass.class).web(false)
                                                                                                   .run(args);
        SparkJob job = ctx.getBean(SparkJob.class);
        job.prepareJobAndRun();
        ctx.close();
    }
}

      

when i add

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.mypackage.MyMainClass

      

everything works as expected, but I don't want to add them manually. Any chance to make this work without spring-boot-maven-plugin

?

+3


source to share


1 answer


I was able to find out that you can add your own META-INF/spring.factories

in src/main/resources

. These custom spring.factories will then be packaged in a jar. Tested, works.



+5


source







All Articles