Spring Boot Application Not Starting and no exception

Viewed 2992

I am using spring boot version: 2.3.5.RELEASE, with only the main class which I am trying to start. When I run the main class, I get the below message and the application fails to start without any error.

2020-11-03 12:39:17.871  INFO 15426 --- [           main] com.rahul.poc.HealthcheckApplication     : Starting HealthcheckApplication on INMLTCU6LVCG with PID 15426 (/Users/rahul/Documents/Rahul/Projects/healthcheck/target/classes started by rahul in /Users/rahul/Documents/Rahul/Projects/healthcheck)
2020-11-03 12:39:17.873  INFO 15426 --- [           main] com.rahul.poc.HealthcheckApplication     : No active profile set, falling back to default profiles: default
2020-11-03 12:39:18.617  INFO 15426 --- [           main] com.rahul.poc.HealthcheckApplication     : Started HealthcheckApplication in 1.353 seconds (JVM running for 1.806)

Process finished with exit code 0

The pom.xml looks like below:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.rahul.poc</groupId>
    <artifactId>healthcheck</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Healthcheck</name>
    <description>Healthcheck POC</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
<!--            <scope>test</scope>-->
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

The main class as:

package com.rahul.poc;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class HealthcheckApplication {

    public static void main(String[] args) {
        SpringApplication.run(HealthcheckApplication.class, args);
    }

}

I don't have any other class or configuration.

1 Answers

I believe that your problem is that you haven't added a starter package reference that adds a server component to your app, or otherwise adds anything that stays alive and does anything. I think your app is running, and then exiting because it has not been configured to run anything on a continual basis.

The most common thing you're missing that would cause your app to stay running is the web starter. Add this as a Maven dependency, and you should get behavior more like what you expect:

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