springboot报Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory

一.背景

    从网上下载一份基于maven构建springboot2.0的demo,运行,然后报错。工具:idea

二。错误信息

在springboot启动的过程中报没有找到ServletWebServerFactory这个bean的实例,错误信息如下:springboot报Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory_第1张图片

三。问题分析

1。启动报错,并且这个类(ServletWebServerFactory)(这个类干什么的这里先不介绍)来自于springboot包中,并不是由于应用代码报的错,那么网上已经有很多人遇到过,别想那么多,盘它。

搜索到博文https://www.cnblogs.com/gudi/p/8711606.html,https://blog.csdn.net/qq_43123875/article/details/82351985,https://stackoverflow.com/questions/46463908/unable-to-start-servletwebserverapplicationcontext-due-to-missing-servletwebserv

发现都不能解决我的问题,文章也并没有说清楚介绍的问题的根源。

2。还是自己来吧,

那就照着spring大大给我的提示,Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.  开始debug把。

找到了报错的地方

springboot报Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory_第2张图片

beanFactory中并没有ServletWebServerFactory实现类的实例。怎么办呢,spring初始化的过程已经忘得差不多了,冷静,要相信spring不会犯这种错,犯错的只能是本人。那么先看看ServletWebServerFactory 这个类把

springboot报Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory_第3张图片

看上去也没什么呀,不对,右上角有个红色的小图标,那么问题浮现了,org.apache.catalina ,这个包不存在。

该包是来自tomcat-embed-core-8.5.31.jar中,那么不对呀,该项目是有引入此包的,springboot已经内嵌了tomcat


   org.springframework.boot
   spring-boot-starter-web

这个配置项是有的。那我们去maven本地仓库找找把,过不其然,空有tomcat-embed-core-8.5.31.jar此包,此包打开一看没有一个文件

springboot报Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory_第4张图片

 

那么问题已经明了,删除此包,重新拉取,搞定啦。

 

 

 

 

你可能感兴趣的:(springboot报Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory)