`

springboot 引入servlet报错

阅读更多
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.1.RELEASE)

2017-06-20 21:12:58.622  INFO 7560 --- [           main] com.springboot.app.App                   : Starting App on chuichuige-PC with PID 7560 (G:\workspace\sts-workspace\spring-boot-jsp\target\classes started by chuichuige in G:\workspace\sts-workspace\spring-boot-jsp)
2017-06-20 21:12:58.637  INFO 7560 --- [           main] com.springboot.app.App                   : No active profile set, falling back to default profiles: default
2017-06-20 21:12:58.714  INFO 7560 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6a400542: startup date [Tue Jun 20 21:12:58 CST 2017]; root of context hierarchy
2017-06-20 21:13:01.105  INFO 7560 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-06-20 21:13:01.123  INFO 7560 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2017-06-20 21:13:01.124  INFO 7560 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.5
2017-06-20 21:13:01.257 ERROR 7560 --- [cat-startStop-1] org.apache.catalina.core.ContainerBase   : A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
	at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_131]
	at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_131]
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:911) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:890) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.5.jar:8.5.5]
	... 6 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [Pipeline[StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5099) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
	... 6 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.authenticator.NonLoginAuthenticator[]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.StandardPipeline.startInternal(StandardPipeline.java:170) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
	... 8 common frames omitted
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
	at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1122) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
	... 10 common frames omitted

2017-06-20 21:13:01.259 ERROR 7560 --- [           main] org.apache.catalina.core.ContainerBase   : A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
	at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:1.8.0_131]
	at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[na:1.8.0_131]
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:911) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:791) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.startup.Tomcat.start(Tomcat.java:356) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:96) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:82) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:535) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:177) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535) [spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at com.springboot.app.App.main(App.java:9) [classes/:na]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_131]
	at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_131]
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:890) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
	... 6 common frames omitted

2017-06-20 21:13:01.260  WARN 7560 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
2017-06-20 21:13:01.268 ERROR 7560 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:535) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at com.springboot.app.App.main(App.java:9) [classes/:na]
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:115) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:82) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:535) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:177) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	... 8 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.startup.Tomcat.start(Tomcat.java:356) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:96) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
	... 13 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:791) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	... 15 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	... 17 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
	... 19 common frames omitted

 原因分析:由于springboot里面继承了servlet,所以会导致jar冲突

 

 

 解决方案

 

  方案一: 把springboot继承的tomcat的servlet的jar包排除(比较麻烦)

 

  方案二:把springboot外部引入的jar依赖去除即可(推荐方案)

 

 

 

0
2
分享到:
评论

相关推荐

    servlet_api.jar 包,当遇到servlet报错是就是没有这个包

    servlet_api.jar 包,当遇到servlet报错是就是没有这个包,特别是myeclipse转eclipse时

    Javaweb解决webServlet报错的方法

    Javaweb解决webServlet报错的方法

    SpringBoot 注册自己的Servlet(三种方式)(源代码)

    SpringBoot 注册自己的Servlet(三种方式)(源代码) ...目前使用Spring的,更多是在web方面,所以Spring更多的是依赖Servlet容器,哪怕是springboot擅长做独立可执行的微服务应用程序,其内部也包含一个嵌入式Jetty。

    springboot-Servlet3.0过滤器

    在Spring Boot应用中,Servlet 3.0过滤器(Filter)是实现请求处理前和处理后逻辑的重要组件。过滤器可以拦截HTTP请求,对请求和响应进行预处理和后处理,比如登录验证、数据编码解码、日志记录等。Spring Boot通过...

    SpringBoot注册Servlet的三种方法详解

    Servlet 3.0引入了一种新的注册方式,可以通过注解直接在类上声明Servlet,Filter和Listener。使用`@WebServlet`注解可以替代web.xml中的servlet配置。例如: ```java import javax.servlet.annotation....

    SpringBoot整合Servlet的两种方式.docx

    Spring Boot提供了一种简洁的方式来集成Servlet,使得我们不再需要传统的web.xml配置文件。本文将详细介绍两种整合Servlet的方法。 1. **通过注解扫描完成Servlet组件注册** 在这种方法中,我们首先创建一个新的...

    SpringBoot+文件上传

    `StandardServletMultipartResolver`是Spring MVC处理多部分请求(即包含文件上传的HTTP请求)的默认解析器,它依赖于Servlet容器的Multipart配置。 首先,让我们深入了解一下Spring Boot中的文件上传流程: 1. **...

    SpringBoot3 使用Druid报错,配置不生效,404报错

    这可能导致在SpringBoot3中引入Druid时启动报错。此外,SpringBoot2使用的是`com.alibaba.druid.support.http.StatViewServlet`,而SpringBoot3则改为`com.alibaba.druid.support.jakarta.StatViewServlet`,这也是...

    springboot注入servlet的方法

    Spring Boot 注入 Servlet 的方法 Spring Boot 框架提供了多种方式来注入 Servlet,从而实现 Web 应用程序的开发。在本文中,我们将介绍 Spring Boot 注入 Servlet 的方法,并分析为什么需要使用 ...

    springboot实现web系统Licence验证

    在IT行业中,软件许可(License)验证是保护知识产权和确保软件合规使用的重要环节。Spring Boot是一个流行的Java开发框架,用于快速构建高效的Web应用程序。在这个场景下,我们将探讨如何使用Spring Boot来实现一个...

    SpringBoot配置详解

    SpringBoot配置详解 Spring Boot应用程序 Properties配置详解 Spring Boot是一种基于Java的开源框架,旨在简化基于Spring的应用程序的开发。Spring Boot提供了许多特性,包括自动配置、starter依赖项、外部化配置...

    Spring Boot实现异步请求(Servlet 3.0)

    Spring Boot 实现异步请求(Servlet 3.0) Spring Boot 实现异步请求是指在 Spring Boot 应用程序中使用异步处理机制来处理请求,以提高系统的性能和吞吐量。在 Spring 3.2 及以后版本中增加了对请求的异步处理,...

    springboot乱码问题解决方案

    SpringBoot乱码问题解决方案 SpringBoot框架是一款流行的Java Web开发框架,但是在实际开发中,开发者经常会遇到乱码问题,导致项目无法正常运行。为了解决这个问题,本文将详细介绍SpringBoot乱码问题解决方案,并...

    SpringBoot之配置嵌入式Servlet容器.pdf

    标题“SpringBoot之配置嵌入式Servlet容器.pdf”透露了文档的核心内容,主要讲解了在SpringBoot框架中如何配置和使用嵌入式Servlet容器。SpringBoot作为一个广泛使用的Java框架,它的一个显著优势就是能快速搭建项目...

    SpringBoot如何注册Servlet、Filter、Listener的几种方式

    在Servlet 3.0之前,我们通常依赖于`web.xml`文件来配置Servlet、Filter和Listener,但随着技术的进步,SpringBoot提供了更加灵活的注册方式。本文将详细介绍SpringBoot中注册Servlet、Filter和Listener的两种方法。...

    原生Servlet与Spring Controller性能比较--Controller项目

    本篇文章将深入探讨原生Servlet与Spring Controller在性能方面的差异,并以"Controller项目"为例进行分析。 Servlet是Java EE规范的一部分,它提供了一个标准的方式来处理HTTP请求和响应。原生Servlet直接继承自`...

    SpringBoot配置嵌入式Servlet容器和使用外置Servlet容器的教程图解

    SpringBoot配置嵌入式Servlet容器和使用外置Servlet容器的教程图解 本文主要介绍了SpringBoot配置嵌入式Servlet容器和使用外置Servlet容器的教程,通过图文并茂的形式给大家介绍的非常详细,对大家的学习或工作具有...

    springboot初学者必备代码.zip

    013-springboot-servlet 014-springboot-filter 015-springboot-character-filter 016-springboot-character-properties 017-springboot-mapper 018-springboot-mapperscan 019-springboot-transactional .......

    Spring Boot 使用 ProxyServlet 代理并统一响应

    1. 添加依赖:在`pom.xml`文件中引入Spring Boot的`spring-boot-starter-web`依赖,以及Tomcat的`tomcat-embed-jasper`依赖,它们包含了Servlet的实现。 ```xml &lt;groupId&gt;org.springframework.boot ...

Global site tag (gtag.js) - Google Analytics