今天碰到這個錯,真的頭痛,讓人哭笑不得
springboot啟動報錯:
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean. at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:206) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
最后解決:
SpringApplication.run方法第一個參數傳錯了:錯:SpringApplication.class ,換成:StartBootTestApplication.class。引以為戒
@SpringBootApplication @EnableAsync public class StartBootTestApplication { public static void main(String[] args) { SpringApplication.run(SpringApplication.class,args); } }