当前位置: 首页 > 知识库问答 >
问题:

springboot - pom文件问题:更正应用程序的类路径,使其包含类 ?

王宏扬
2023-06-27

他推荐我的操作是:更正应用程序的类路径,使其包含类 org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory 和 org.apache.catalina.Context 的兼容版本

这是控制台的error


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

The following method did not exist:

    'void org.apache.catalina.Context.addServletContainerInitializer(jakarta.servlet.ServletContainerInitializer, java.util.Set)'

The calling method's class, org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory, was loaded from the following location:

    jar:file:/C:/Users/hp7/.m2/repository/org/springframework/boot/spring-boot/3.1.0/spring-boot-3.1.0.jar!/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.class

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

    jar:file:/D:/apache-tomcat-9.0.70/lib/catalina.jar!/org/apache/catalina/Context.class

The called method's class hierarchy was loaded from the following locations:

    org.apache.catalina.Context: file:/D:/apache-tomcat-9.0.70/lib/catalina.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory and org.apache.catalina.Context

更正应用程序的类路径,使其包含类 org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory 和 org.apache.catalina.Context 的兼容版本

进程已结束,退出代码0

共有2个答案

伍心水
2023-06-27

有人吗可以解决一下吗

熊俊人
2023-06-27

你的操作是正确的,你是打算更正应用程序的类路径,从而来包含 Tomcat Web 服务器所需的所有类。但是你应该遇到了兼容问题
根据报错的英文翻译过来的意思是“版本兼容性有问题,该方法在调用时需要 org.apache.catalina.Context 类的 addServletContainerInitializer() 方法,但是 addServletContainerInitializer() 方法在您的应用程序中并不存在”
OIP-C.jpg
因此你可以检查应用程序的依赖项和版本,确保它们与 Tomcat 版本兼容,并尝试更正类路径。如果问题仍然存在,我建议你可以尝试升级依赖项版本或更换更新的 Tomcat 版本。

 类似资料: