【Maven】javax.servlet.ServletContext 引用失敗

在我爲項目設定 parent pom的時候遇上了一個問題,

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

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:/Users/12dong/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar!/javax/servlet/ServletContext.class
    jar:file:/Users/12dong/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.17/tomcat-embed-core-9.0.17.jar!/javax/servlet/ServletContext.class

It was loaded from the following location:

    file:/Users/12dong/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar


Action:

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

從description可以看出我的項目關於servlet-api的引用又有兩處用到了,只要把我顯式引用的pom dependency刪除就好了。

但不知道爲什麼如果僅僅把parent pom 改爲idea 默認的springboot-pom可以使用,但是換成我自己創建的parent pom就不能使用了,即使我自己創建的parent pom 的 parent pom 也是idea 默認的springboot-pom。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章