【亲测可用】Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean

作者 : admin 本文共990个字,预计阅读时间需要3分钟 发布时间: 2024-03-4 共1人阅读

启动报错

Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean

scope属性的可选值释义

其中scope属性值为provided,对于scope属性的可选值释义如下:

compile (编译):为默认范围,其意义在于默认没有提供一个范围,则该项目依赖的范围就是编译范围。使用该值会导致编译范围依赖在所有的classpath中是可用的,同时在打包时候将包含这些依赖;
provided (已提供):依赖只有在当JDK 或者一个容器已提供该依赖之后才使用。例如, 如果你开发了一个web 应用,你可能在编译 classpath 中需要可用的Servlet API 来编译一个servlet,但是你不会想要在打包好的WAR 中包含这个Servlet API;这个Servlet API JAR 由你的应用服务器或者servlet 容器提供。已提供范围的依赖在编译classpath (不是运行时)可用。它们不是传递性的,也不会被打包;
runtime (运行时):依赖在运行和测试系统的时候需要,但在编译的时候不需要。比如,你可能在编译的时候只需要JDBC API JAR,而只有在运行的时候才需要JDBC
驱动实现;
test (测试):范围依赖 在一般的编译和运行时都不需要,它们只有在测试编译和测试运行阶段可用;
system (系统):范围依赖与provided类似,但是你必须显式的提供一个对于本地系统中JAR文件的路径。这么做是为了允许基于本地对象编译,而这些对象是系统类库的一部分。这样的构建应该是一直可用的,Maven 也不会在仓库中去寻找它。如果你将一个依赖范围设置成系统范围,你必须同时提供一个systemPath元素。注意该范围是不推荐使用的(建议尽量去从公共或定制的 Maven 仓库中引用依赖);

解决办法

打开IDEA Edit Configurations页面

【亲测可用】Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean插图

勾选Include dependenceies with “Provided” scope选项,然后点击OK保存:

【亲测可用】Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean插图(1)【亲测可用】Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean插图(2)

之后再运行项目就不会有该报错,问题解决。

参考

【启动报错】Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean-CSDN博客

本站无任何商业行为
个人在线分享 » 【亲测可用】Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean
E-->