spring-bootmavenspring-boot-maven-plugin

How to run a spring executable jar where main class is present in one of the dependencies lib


I am working on a springboot project where the generated spring executable jar has the following structure.

BOOT-INF/
----classes/ <nothing inside classes>
----lib/
---------myDependency.jar ----> (This contains the Main Class)
---------anotherDependency.jar
META-INF/
org
----springframework ...

My SpringBootApplication Main class is present in myDependency.jar Problem is - as the Spring Boot JarLauncher class, as documented here assumes that the Main class will be present in BOOT-INF/classes folder, that is why it is NOT able to find the main class from inside myDependency.jar.

Is there any way to tell Spring boot to read the Main class from the jar file inside BOOT-INF/lib instead of BOOT-INF/classes


Solution

  • I am able to find the mistake now. Will post here for others reference. Basically the Main class can be present in the dependency JAR file and it will work if the JAR structure is standard. In my case, myDependency.jar was structured like a Spring Boot executable jar that is why it was not able to find the required Main class. And reason for that was the spring-boot-maven-plugin which I removed. Hope this helps.