今天碰到这个错,真的头痛,让人哭笑不得

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);
    }
}

 

相关文章:

  • 2021-07-27
  • 2021-06-29
  • 2021-08-04
  • 2022-12-23
  • 2021-12-30
  • 2021-09-15
猜你喜欢
  • 2021-12-11
  • 2021-10-07
  • 2022-12-23
相关资源
相似解决方案