Reputation: 176
I am new with Spring Boot and failed to create a self-contained executable jar. The Maven created jar fails to detect the Beans that it needs at runtime.
Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
I checked the factory if an implementation of the factory is in the jar which is the case. I also carefully checked other posts and made sure that the Spring Boot annotation is in place. It includes the @ComponentScan and others.
@SpringBootApplication
public class InitService {
I assume that my pom has the dependencies correctly set, because the application runs well when I start it from my Eclipse project.
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>de.newbe.create.InitService</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
So now I challenge the community and hope for your valuable expertise and support. Thanks in advance!
Upvotes: 4
Views: 2746
Reputation: 12184
I would try to setup the project like here (see pom.xml) https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-simple
A simple mvn package
should be enough to generate the jar.
See here for details - http://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html#build-tool-plugins-maven-plugin
Upvotes: 7