启动SpringBoot的时候出现异常
public class Application {
public static void main(String[] args) {
SpringApplication.run(SpringApplication.class,args);
}
}
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:210) ~[spring-boot-2.6.6.jar:2.6.6] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180) ~[spring-boot-2.6.6.jar:2.6.6] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160) ~[spring-boot-2.6.6.jar:2.6.6] ... 8 common frames omitted
原因:Application类名与run方法中使用的类SpringBoot.class不一致
修改:
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class,args);
}
}