Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring autoconfiguration class is missing in META-INF/spring.factories

I'm trying to create spring based application but after the build i'm getting exception while initializing the spring context -> No auto configuration classes found in META-INF/spring.factories. I'm working heavily with spark in my application and i'm forced to use maven-assembly-plugin to package my jar (otherwise i'm unable to run 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 the spring-boot-maven-plugin?

like image 649
Martin Brisiak Avatar asked Apr 24 '17 11:04

Martin Brisiak


1 Answers

I was able to found out, that you can add your own META-INF/spring.factories to src/main/resources. This custom spring.factories will be then packed to jar. Tested, working.

like image 173
Martin Brisiak Avatar answered Nov 15 '22 00:11

Martin Brisiak