Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean?-灵析社区

周舟莫UI设计

启动springboot项目时报错, 报错信息如下: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean. at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:157) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE] at cn.ethan.chatgpt.Application.main(Application.java:17) [classes/:na] 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.3.RELEASE.jar:2.1.3.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154) ~[spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE] ... 8 common frames omitted 启动具体代码如下: @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } Pom文件依赖如下: org.springframework.boot spring-boot-starter-security 2.1.3.RELEASE org.springframework.boot spring-boot-starter-web 2.7.14 org.springframework.boot spring-boot-starter-tomcat 3.1.2 io.jsonwebtoken jjwt-api 0.11.2 io.jsonwebtoken jjwt-impl 0.11.2 io.jsonwebtoken jjwt-jackson 0.11.2 commons-codec commons-codec 1.15 javax.servlet javax.servlet-api 3.1.0 provided 做过的尝试有: 1. 检查并更换@SpringBootApplication注解 2. 更新pom文件中的starter-tomcat依赖 3. 修改pom文件中的provided 经过@TNT的回答, 我将pom文件中的tomcat依赖注释, 并把starter-web和stater-security的依赖版本号设置成一致后, 问题得到解决.

阅读量:369

点赞量:8

问AI
把 spring-boot-starter-tomcat 这个依赖去掉,上面的 starter-web 里带了 你自己加了还把版本加错了…