问题描述
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-08-27T10:54:06.452+08:00 ERROR 30624 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Web application could not be started as there was no org.springframework.boot.web.servlet.server.ServletWebServerFactory bean defined in the context.
Action:
Check your application's dependencies for a supported servlet web server.
Check the configured web application type.
解决方法
首先,是先看自己的pom文件是否引入了web依赖,如果没有引入的话。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
如果问题没有解决的话,还有一种就是tomocat的问题,看父pom中是否将tomocat排除了。
这种情况产生的原因就是:
Spring Boot 需要一个嵌入式 Web 服务器来启动 Web 应用程序。默认情况下,Spring Boot 使用 Tomcat 作为嵌入式服务器。如果你排除了 spring-boot-starter-tomcat
,并且没有添加其他嵌入式 Web 服务器(如 Undertow 或 Jetty),那么 Spring Boot 会抛出这个错误。
解决方法就是使用其他的嵌入式Web服务器(如 Undertow 或 Jetty)
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-undertow</artifactId> </dependency>