Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean
在Spring Boot项目中,出现这个错误有两种情况:
一,在main方法所在的类忘记添加@SpringBootApplication
二,缺少依赖,添加即可
1
2
3
4
|
|
如果以上两种都检查没问题,那么就手动配置该bean
在配置 @Configuration注解的类中 增加以下代码
@Bean
public ServletWebServerFactory servletWebServerFactory(){
return new TomcatServletWebServerFactory();
}
原文:https://www.cnblogs.com/javahepeng/p/14849034.html