Why Spring Boot shutdowns right after it's started?

June 25, 2019 No comments Spring Boot QA Spring

If you are struggling with the following output on your Spring Boot application console:

.   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.5.RELEASE)

2018-10-16 11:07:18.646  INFO 10615 --- [           main] com.frontbackend.Application             : Starting Application on dell with PID 10615 (/home/frontbackend/target/classes started by frontbackend in /home/frontbackend)
2018-10-16 11:07:18.652  INFO 10615 --- [           main] com.frontbackend.Application             : No active profile set, falling back to default profiles: default
2018-10-16 11:07:18.688  INFO 10615 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4f638935: startup date [Tue Oct 16 11:07:18 CEST 2018]; root of context hierarchy
2018-10-16 11:07:19.492  INFO 10615 --- [           main] org.mongodb.driver.cluster               : Cluster created with settings {hosts=[localhost:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2018-10-16 11:07:19.492  INFO 10615 --- [           main] org.mongodb.driver.cluster               : Adding discovered server localhost:27017 to client view of cluster
2018-10-16 11:07:19.607  INFO 10615 --- [localhost:27017] org.mongodb.driver.connection            : Opened connection [connectionId{localValue:1, serverValue:4}] to localhost:27017
2018-10-16 11:07:19.609  INFO 10615 --- [localhost:27017] org.mongodb.driver.cluster               : Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 21]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=817693}
2018-10-16 11:07:19.610  INFO 10615 --- [localhost:27017] org.mongodb.driver.cluster               : Discovered cluster type of STANDALONE
2018-10-16 11:07:19.688  INFO 10615 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-10-16 11:07:19.699  INFO 10615 --- [           main] com.frontbackend.Application             : Started Application in 1.282 seconds (JVM running for 1.739)
2018-10-16 11:07:19.702  INFO 10615 --- [       Thread-5] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@4f638935: startup date [Tue Oct 16 11:07:18 CEST 2018]; root of context hierarchy
2018-10-16 11:07:19.705  INFO 10615 --- [       Thread-5] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

Process finished with exit code 0

most likely there is a missing major dependency in your configuration. The above situation happens when Spring Boot application is not treated as web application (webapp), because the embedded web container is missing.

You should add spring-boot-starter-web starter that is responsible for setting up embedded container.

If you are using Maven, go to pom.xml file and add spring-boot-starter-web dependency:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

For gradle, go to build.gradle and add below line:

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-web'
}
{{ message }}

{{ 'Comments are closed.' | trans }}