ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean
Case 1:
@SpringBootApplication
annotation missing in your spring boot starter class.
Case 2:
For non web application, disable web application type
in properties file:
In application.properties
:
spring.main.web-application-type=none
If you use application.yml
then add:
spring:
main:
web-application-type: none
For web applications, extends *SpringBootServletInitializer*
in main class.
@SpringBootApplication
public class YourAppliationName extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(YourAppliationName.class, args);
}
}
Case 3:
If you use spring-boot-starter-webflux
then also add spring-boot-starter-web
as dependency.
Probably you missing @SpringBootApplication
in your spring boot starter class.
@SpringBootApplication
public class LoginSecurityAppApplication {
public static void main(String[] args) {
SpringApplication.run(LoginSecurityAppApplication.class, args);
}
}
The solution is:
I explicitly set the below property to none
in application.yml
file.
spring:
main:
web-application-type: none