美文网首页
java.lang.NoSuchMethodError: jav

java.lang.NoSuchMethodError: jav

作者: AC编程 | 来源:发表于2018-09-19 17:32 被阅读1138次

一、启动SpringBoot失败,异常信息如下

An attempt was made to call the method javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String; but it does not exist. Its class, javax.servlet.ServletContext, is available from the following locations:

    jar:file:/Users/ac/.gradle/caches/modules-2/files-2.1/javax.servlet/servlet-api/2.4/3fc542fe8bb8164e8d3e840fe7403bc0518053c0/servlet-api-2.4.jar!/javax/servlet/ServletContext.class
    jar:file:/Users/ac/.gradle/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-core/8.5.34/a038040d68a90397f95dd1e11b979fe364a5000f/tomcat-embed-core-8.5.34.jar!/javax/servlet/ServletContext.class

It was loaded from the following location:

    file:/Users/ac/.gradle/caches/modules-2/files-2.1/javax.servlet/servlet-api/2.4/3fc542fe8bb8164e8d3e840fe7403bc0518053c0/servlet-api-2.4.jar

二、解决

servlet-api版本太低,升级即可
剔除旧版本

configurations {
        compile.exclude module: 'servlet-api'
    }

配置新版本

compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'

相关文章

网友评论

      本文标题:java.lang.NoSuchMethodError: jav

      本文链接:https://www.haomeiwen.com/subject/uuoinftx.html