您的位置:首页 > 移动开发 > WebAPP

Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.

2017-01-12 18:52 866 查看

问题描述

最初使用Spring boot进行建立了一个web项目,能够对http请求进行响应,支持REST风格访问。现在想去除web特性,从而不再有端口依赖。于是将对应依赖由spring-boot-starter-web修改成spring-boot-starter,修改完之后,项目无法启动报错信息如下:

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:133)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)
at com.hhly.information.InformationApplication.main(InformationApplication.java:25)
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:185)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:158)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 8 common frames omitted


问题分析

参考下面的说法结合自身的项目,推测应该是项目中还有web特性,导致项目无法启动。



解决办法

于是去掉了对应的servlet、spring-web对应的依赖,可是,通过查看项目maven依赖列表,列表中还是存在spring-web的依赖,其他包引入了spring-web的依赖。

通过IDEA Maven–>Show Dependencies发现spring-hateoas包中有引入spring-web的包,于是去除对应依赖,问题解决。



参考:

https://github.com/spring-projects/spring-boot/issues/861
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐