springboot项目运行报错Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean

Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.

最近开始使用idea,上来就这么一个错误。搜索总结如下:

我的依赖是这样的:

springboot项目运行报错Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean

provided 依赖只有在当JDK 或者一个容器已提供该依赖之后才使用。例如, 如果你开发了一个web 应用,你可能在编译

classpath 中需要可用的Servlet API 来编译一个servlet,但是你不会想要在打包好的WAR 中包含这个Servlet API;这个

Servlet API JAR 由你的应用服务器或者servlet 容器提供。已提供范围的依赖在编译classpath (不是运行时)可用。它们

不是传递性的,也不会被打包。

在 Intellij Idea 15 中使用maven时,所有 scope 为 provided 的依赖都是不会被加入到 classpath 中的,目前该bug尚未被修复(bug report)。如果你的web应用是部署到容器中的,那么这个bug不会影响使用,因为web应用中provided的依赖在容器运行时会被提供。如果你做Spring Boot开发,有带provided的依赖时,直接在IDE中运行项目会导致ClassNotFound异常。解决方案有二:

使用spring-boot:run这个 maven goal 运行程序。但这样会失去 Idea 的 debug功能,不推荐。
点击IDE右侧的Maven Projects, 找到spring-boot:run,右键选择 debug 运行,如图:

springboot项目运行报错Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean

Original: https://www.cnblogs.com/qianzf/p/14586075.html
Author: 锋齐叶落
Title: springboot项目运行报错Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/541240/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球