Spring boot - java.lang.ClassNotFoundException: javax.servlet.ServletContext and Unable to start EmbeddedWebApplicationContext

The issue was with the build.gradle

provided "org.springframework.boot:spring-boot-starter-tomcat"

Intellij wasn't happy with the provided

as soon as I switched to

compile "org.springframework.boot:spring-boot-starter-tomcat"

the application worked


Run with maven spring boot goal: spring-boot:run

Steps to setup maven configuration in IntelliJ:

Debug/Run Configuration | Click on + button visible at top left | Select Maven | Set command line to spring-boot:run


Adding dependency below fixed my issue:

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

Remember to have parent dependency as well!