[Fix] Springboot: Web application could not be started as there was no ServletWebServerFactory bean defined in the context.


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

2023-04-07T14:32:51.059+05:30 ERROR 2732 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:
Web application could not be started as there was no 
org.springframework.boot.web.servlet.server.ServletWebServerFactory bean defined in the context.

Action:
Check your application's dependencies for a supported servlet web server.
Check the configured web application type.

Fix:
  1. Make sure Springboot Web (or other required) dependency has been added to the Maven/Gradle file.

    build.gradle
    implementation 'org.springframework.boot:spring-boot-starter-web'

    pom.xml
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
  2. Make sure you have made use of the correct annotation i.e. @SpringBootApplication on the class that contains the main method.

    Example:
    @SpringBootApplication
    public class ToDoApplication {
    
    	public static void main(String[] args) {
    		SpringApplication.run(ToDoApplication.class, args);
    	}
    }
SpringBootApplication annotation on Class with main method

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap