簡體   English   中英

Spring/Gradle - servlet-api 依賴問題

[英]Spring/Gradle - servlet-api dependency issue

一般來說,Gradle 仍然很新,所以希望這不是一個愚蠢的問題,但我在運行容器時遇到了這個問題(這會立即使容器崩潰)。

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:1319)

The following method did not exist:

    'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'

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

    jar:file:/app/lib/servlet-api-2.5-6.1.14.jar!/javax/servlet/ServletContext.class
    jar:file:/app/lib/javax.servlet-api-4.0.1.jar!/javax/servlet/ServletContext.class
    jar:file:/app/lib/tomcat-embed-core-9.0.62.jar!/javax/servlet/ServletContext.class
    jar:file:/app/lib/servlet-api-2.5-20081211.jar!/javax/servlet/ServletContext.class

The class hierarchy was loaded from the following locations:

    javax.servlet.ServletContext: file:/app/lib/servlet-api-2.5-6.1.14.jar


Action:

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

我試過添加

configurations.all {
    exclude group: '', module: 'servlet-api'
}

但它看起來刪除了另一個版本的servlet api(錯誤指定它正在查找servlet-api-2.5-6.1.14.jar,但它刪除了servlet-api-2.5-20081211.jar,因為構建和運行后錯誤output就是現在:

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

    jar:file:/app/lib/servlet-api-2.5-6.1.14.jar!/javax/servlet/ServletContext.class
    jar:file:/app/lib/javax.servlet-api-4.0.1.jar!/javax/servlet/ServletContext.class
    jar:file:/app/lib/tomcat-embed-core-9.0.62.jar!/javax/servlet/ServletContext.class

The class hierarchy was loaded from the following locations:

    javax.servlet.ServletContext: file:/app/lib/servlet-api-2.5-6.1.14.jar

我已經運行了一個依賴任務,servlet-api 依賴於 org.apache.hadoop:hadoop-core:1.2.1

go 解決此問題的最佳方法是什么? 我試過排除並給出確切的版本號,但這似乎不起作用。 我還嘗試添加更新版本的 hadoop 核心依賴項(它將與更新版本的 servlet-api 捆綁在一起。因為我相信我需要 3.1+(我有 2.5)),但這似乎也沒有工作

我認為錯誤

以下方法不存在:

 'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'

是因為你的servlet API 的版本早於3.1,3.1及之后的版本引入了getVirtualServerName()方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM