Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean

在Spring Boot项目中,出现这个错误有两种情况:

一,在main方法所在的类忘记添加@SpringBootApplication

二,缺少依赖,添加即可

1 2 3 4 <dependency>     <groupId>org.springframework.boot</groupId>     <artifactId>spring-boot-starter-web</artifactId> </dependency>

 

 如果以上两种都检查没问题,那么就手动配置该bean   在配置 @Configuration注解的类中  增加以下代码    

@Bean
public ServletWebServerFactory servletWebServerFactory(){
return new TomcatServletWebServerFactory();
}

 
上一篇:Outlook2013中"Unable to log in to: SharePoint" 错误的解决方案


下一篇:Emulator: emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037