码上敲享录 > Spring框架常见问题详解分享 > springboot启动报错missing EmbeddedServletContainerFactory bean

springboot启动报错missing EmbeddedServletContainerFactory bean

上一章章节目录下一章 2017-12-04已有8930人阅读 评论(0)

springboot启动报错missing EmbeddedServletContainerFactory bean


问题描述:

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.

就是无法启动嵌入式容器,也就是说不能找不到嵌入的tomcat(也称内置tomcat)。


解决方法:

配置Tomcat中的方式

方式一:用spring-boot内置的tomcat库,并指定你要部署到Tomcat的版本

<dependency>

   <groupId>org.apache.tomcat</groupId>

   <artifactId>tomcat-juli</artifactId>

   <version>7.0.69</version>

</dependency>


方式二:不用spring-boot内置的tomcat库(强烈推荐这种方式,方便自定义配置!)

<!-- 打war包时加入此项,provided 告诉spring-boot tomcat相关jar包用外部的,不要打进去 -->

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

<exclusions>

<!-- 移除嵌入式tomcat插件 -->

<exclusion>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-tomcat</artifactId>

</exclusion>

</exclusions>

</dependency>

<dependency>

<groupId>javax.servlet</groupId>

<artifactId>javax.servlet-api</artifactId>

<scope>provided</scope>

</dependency>

其中,provided 依赖只有在当JDK或者一个容器已提供该依赖之后才使用。例如,如果你开发了一个web应用,你可能在编译classpath 中需要可用的Servlet API 来编译一个servlet,但是你不会想要在打包好的WAR中包含这个Servlet API;这个Servlet API JAR 由你的应用服务器或者servlet容器提供。

本文地址:http://www.yayihouse.com/yayishuwu/chapter/1051

向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti
1

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交