编程语言
首页 > 编程语言> > The following method did not exist:javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/Str

The following method did not exist:javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/Str

作者:互联网

SpringBoot 启动失败。又是jar冲突,这是第几次了?

报错细节

报错细节:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1355)

The following method did not exist:

    javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;

The method's class, javax.servlet.ServletContext, is available from the following locations:

    jar:file:/opt/ETC/xxl-job-executor-etc/run/lib/servlet-api-2.5.jar!/javax/servlet/ServletContext.class
    jar:file:/opt/ETC/xxl-job-executor-etc/run/lib/tomcat-embed-core-9.0.41.jar!/javax/servlet/ServletContext.class

The class hierarchy was loaded from the following locations:

    javax.servlet.ServletContext: file:/opt/ETC/xxl-job-executor-etc/run/lib/servlet-api-2.5.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of javax.servlet.ServletContext

分析错误

描述信息大概意思是:你在调用一个不存在的方法,该方法可以在xxx位置找到。

what fk ?看到17行18行瞬间反应过来,这个方法在两个jar中都有,并且类路径完全相同,jre懵逼了,不知道调用哪个,然后将问题抛出来给开发者:你必须让我能够明确知道调用哪个。

接下来事情就明确了,我们需要剔除多余的重复jar,本次示例的冲突是servlet-api,由于SpringBoot默认是使用内嵌的tomcat启动,所以应该是其他的依赖中重复导入了这个依赖,直接进行排除就OK了。

怎么排出重复依赖?

标签:lang,Ljava,依赖,String,jar,ServletContext,following,servlet,javax
来源: https://www.cnblogs.com/langkyeSir/p/15301926.html