zoukankan      html  css  js  c++  java
  • springBoot启动报 `NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;`问题解决

    springBoot启动报 NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;问题解决

    • 在项目的根目录下 查看是哪个包将serlet-api引入的 使用 mvn dependency:tree

    image-20210409161533663

    • 将这个包排除掉
    <dependency>
                <groupId>com.atgui.crowd</groupId>
                <artifactId>atcrowdfundig05-comon-util</artifactId>
                <version>1.0-SNAPSHOT</version>
                <exclusions>
                    <exclusion>
                        <groupId>javax.servlet</groupId>
                        <artifactId>servlet-api</artifactId>
                    </exclusion>
                </exclusions>
    </dependency>
    
    • 问题分析

    我的问题其实不是jar冲突,准备说是ServletContext接口冲突 了。项目依赖了tomcat-embed-core-8.5.31.jar已经有ServletContext了,并且ServletContext接口确确实实定义了getVirtualServerName()方法,只不过jvm先加载了servelt-api中的ServletContext类,后来在加载tomcat-embed-core-8.5.31中的ServletContext时发现它已经存在就不再加载了。

    原文链接:https://blog.csdn.net/a785975139/article/details/80640425

  • 相关阅读:
    文本溢出隐藏与定位
    css基本属性 内边距 外边距及盒模型
    CSS基本属性2
    CSS基本属性
    CSS入门
    表格与表单
    列表与图片
    html标签类型
    HashMap和HashTable
    Map接口
  • 原文地址:https://www.cnblogs.com/zgrey/p/14637712.html
Copyright © 2011-2022 走看看