问题描述
Action: Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.boot.SpringApplication and org.springframework.context.ConfigurableApplicationContext
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location: org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
The following method did not exist:
org.springframework.context.ConfigurableApplicationContext.setApplicationStartup(Lorg/springframework/core/metrics/ApplicationStartup;)V
The calling method's class, org.springframework.boot.SpringApplication, was loaded from the following location: jar:file:/.m2/repository/org/springframework/boot/spring-boot/x.x.x/spring-boot-x.x.x.jar!/org/springframework/boot/SpringApplication.class
The called method's class, org.springframework.context.ConfigurableApplicationContext, is available from the following locations: jar:file:/.m2/repository/org/springframework/spring-context/x.x.x.RELEASE/spring-context-x.x.x.RELEASE.jar!/org/springframework/context/ConfigurableApplicationContext.class
The called method's class hierarchy was loaded from the following locations: org.springframework.context.ConfigurableApplicationContext: file:/.m2/repository/org/springframework/spring-context/x.x.x.RELEASE/spring-context-x.x.x.RELEASE.jar
解决方案
-
错误信息表明的 Spring Boot 应用中 spring-boot 和 spring-context 的版本不匹配。正在使用的是
spring-boot 版本 2.7.17 和 spring-context 版本 5.2.6.RELEASE。这两个版本是不兼容的。 -
解决方案:将 Spring Boot 和 Spring Context 的版本对齐。对于 Spring Boot
2.7.17,应该使用兼容的 Spring Framework 版本,通常是在同一个主要版本和次要版本范围内的版本。查阅 Spring Boot 文档,找出与 2.7.17 兼容的 Spring Framework 版本,并相应地更新的 spring-context 依赖。 -
答主这里是2.7.17与5.2.6.RELEASE 有冲突,具体各位项目中的使用情况,需要单独查询。答主将spring-context的依赖调整成5.3.30后解决。