ThanosGLO
ThanosGLO

Reputation: 23

Spring Boot/Tomcat, "Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean"

I know there are others questions on this, and I have checked them, but none solves my issue.

Very simple POM, ready:ing my app for use with an embedded web server, simply so I can start it up...

<packaging>jar</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
    </parent>

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

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

Very easy Boot class:

@SpringBootApplication
@RestController
public class SpringBootApp {

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

    @RequestMapping(value = "/")
    public String hello() {
        return "Hello World from Tomcat";
    }

}

Tried:

ETC... I do not see why it is not working, I though Spring Boot was supposed to be easy.

Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.

Upvotes: 2

Views: 8651

Answers (1)

Kedar Joshi
Kedar Joshi

Reputation: 1511

First argument for SpringApplication.run() is expected to be the primary configuration class of your application. In your case it is SpringBootApp.class and not SpringApplication.class. Following would be the correct configuration for your Spring Boot application.

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

Upvotes: 3

Related Questions