IDEA启动Spring Boot项目提示Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServlet...
来源:互联网 发布:琴国乐器淘宝店 编辑:程序博客网 时间:2024/05/20 18:15
导入一个
gradle
的Spring Boot
项目,在启动的时候先提示找不到HttpServletRequest
这个包,错误如下:
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletRequest at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_45] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_45] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_45] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_45] ... 29 common frames omitted
但是相应的Java代码没有报错,所以单独找了
servlet-api.jar
导入,并将其添加到Module
中,但是导入后出现另一个错误:
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]....
找了很久都没有找到解决的方法,但是使用
gradle bootrun
是可以正常启动运行的,在另外一台机子上也没有任何问题,所以认为项目本身没有任何问题,是在IDEA启动的过程中出现了问题导致的,看到有一篇使用
Maven
也遇到该问题的帖子,对比了依赖:
dependencies { compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.2.0') compile('org.springframework.boot:spring-boot-starter-web') runtime('mysql:mysql-connector-java') testCompile('org.springframework.boot:spring-boot-starter-test') // this is for generate war file providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')}
然后将
providedRuntime
改成了runtime
,重新build
启动,没有任何问题
该问题产生的原因很可能是因为IDEA在启动的过程中并没有像Gradle
一样做完全的build
,只是进行了热更新,没有将需要的Jar包编译到项目里
providedCompile
和providedRuntime
。虽然它们有各自的compile
和runtime
配置,但这些配置有相同的作用域,只是它们不会添加到war/jar
文件中。
0 0
- IDEA启动Spring Boot项目提示Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServlet...
- Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServlet
- Spring Boot: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFa
- IDEA执行spring boot 出现Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletCont
- 【Spring Cloud】Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletCon
- Idea 启动Sringboot 报错 Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletCont
- Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
- Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
- Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
- Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean
- Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
- Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
- Error : Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory
- Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory Bean
- spring boot启动报Unable to start EmbeddedWebApplicationContext问题解决方案
- Spring-boot Unable to start EmbeddedWebApplicationContext 分析与解决方法
- SpringbootUnable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFact
- Spring Boot jar 启动错误“due to missing embeddedServletContainerFactory.bean”
- JSP数据交互(2)
- IOS自动释放池
- JS实现文字无缝滚动
- aa
- android Binder系列讲解
- IDEA启动Spring Boot项目提示Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServlet...
- 嵌入式系统
- JSP基础
- 用Visual C++轻松实现报表处理
- 题解:纵横字谜的答案(UVa 232)
- OC数据储存本地(二)-----iOS----属性列表plist 写如何存储和读取
- C# excel数据批量导进后添加进数据库中
- 堆栈的定义与操作(链式存储)
- java中的%运算符是取余还是取模?