5

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!

1
  • The maven-assembly-plugin appears to be the wrong choice for Spring Boot will not be able to detect the jars. Instead as Mathias pointed out one needs the spring-boot-maven-plugin. Commented Dec 2, 2015 at 9:00

1 Answer 1

8

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.