java -- 异常 The class hierarchy was loaded from the following locations:

background:

        I recently worked on a project. The code is maven multi-module. A new module was added. After the code was added, an error was reported when starting.

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

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:/I:/apache-maven-3.5.0/repo/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar!/javax/servlet/ServletContext.class
    jar:file:/I:/apache-maven-3.5.0/repo/javax/servlet/javax.servlet-api/4.0.1/javax.servlet-api-4.0.1.jar!/javax/servlet/ServletContext.class
    jar:file:/I:/apache-maven-3.5.0/repo/org/apache/tomcat/embed/tomcat-embed-core/9.0.63/tomcat-embed-core-9.0.63.jar!/javax/servlet/ServletContext.class

The class hierarchy was loaded from the following locations:

    javax.servlet.ServletContext: file:/I:/apache-maven-3.5.0/repo/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar

At first I thought the jar package servlet-api-2.5.jar was missing, but later I found that this package was in the local directory.

reason:

         It turns out that the startup class in the main module already has a startup class, and springboot has a built-in tomcat. When I added a new module, I imported the web basic dependency, which caused a conflict between the two servlets.

 

solve:

        Remove the above redundant dependencies

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-core</artifactId>
        </dependency>

        Reload the project and start again. The result is that it starts normally.

Guess you like

Origin blog.csdn.net/DGH2430284817/article/details/131230346