操作:更正应用程序的类路径,使其包含一个兼容的 org.apache.catalina.Context 版本

问题描述

您好,我正在开发 spring boot,想将 tomcat 版本从 9 升级到 10,为此我已经对 pom.xml 文件进行了以下更改。应用程序在嵌入式 tomcat 版本中运行良好,但当我进行以下更改时,应用程序无法启动。

Q_INVOKABLE

我在启动时收到以下错误。有什么快速帮助吗?

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <!-- <version>2.3.1.RELEASE</version> -->
            <version>2.3.3.RELEASE</version>
            <exclusions>
                <exclusion>
                    <artifactId>jackson-databind</artifactId>
                    <groupId>com.fasterxml.jackson.core</groupId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat</artifactId>
            <version>10.0.5</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-catalina</artifactId>
            <version>10.0.5</version>
        </dependency>


        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
        </dependency> 

我的 pom.xml 文件包含以下依赖项。 :

***************************
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.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.configureContext(TomcatServletWebServerFactory.java:356)

The following method did not exist:

    org.apache.catalina.Context.addServletContainerInitializer(Ljavax/servlet/ServletContainerInitializer;Ljava/util/Set;)V

The method's class,org.apache.catalina.Context,is available from the following locations:

    jar:file:......../.m2/repository/org/apache/tomcat/tomcat-catalina/10.0.5/tomcat-catalina-10.0.5.jar!/org/apache/catalina/Context.class

The class hierarchy was loaded from the following locations:

    org.apache.catalina.Context: file:....../.m2/repository/org/apache/tomcat/tomcat-catalina/10.0.5/tomcat-catalina-10.0.5.jar


Action:

Correct the classpath of your application so that it contains a single,compatible version of org.apache.catalina.Context

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)