看个springboot的tomcat运行bug


Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-06-26T15:24:53.616+08:00 ERROR 22256 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
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: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
    jar:file:/C:/Users/hp7/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/10.1.8/tomcat-embed-core-10.1.8.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


进程已结束,退出代码0

运行之前,项目构建好了吗

是导包的问题噢,如果说你打包好了 放其他地方可以跑,说明你两个地方环境的maven仓库存的jar有出入,有可能你pom文件导入了本地的jar包,你放到外置的Tomcat有这个路径所以可以跑。
检查pom.xml 是否有导入本地jar包
检查maven仓库
用idea检查包是否有冲突