原文的错误:
2023-08-08 21:42:38.518 ERROR 4120 --- [ main] 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.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:/D:/apache-maven-3.9.3/maven_ropo/org/springframework/boot/spring-boot/2.7.5/spring-boot-2.7.5.jar!/org/springframework/boot/SpringApplication.class
The called method's class, org.springframework.context.ConfigurableApplicationContext, is available from the following locations:
jar:file:/D:/apache-maven-3.9.3/maven_ropo/org/springframework/spring-context/5.1.8.RELEASE/spring-context-5.1.8.RELEASE.jar!/org/springframework/context/ConfigurableApplicationContext.class
The called method's class hierarchy was loaded from the following locations:
org.springframework.context.ConfigurableApplicationContext: file:/D:/apache-maven-3.9.3/maven_ropo/org/springframework/spring-context/5.1.8.RELEASE/spring-context-5.1.8.RELEASE.jar
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
Disconnected from the target VM, address: '127.0.0.1:51002', transport: 'socket'
Process finished with exit code 1
解决办法:只需将pom.xml文件中的:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<!-- <version>5.1.8.RELEASE</version>-->这一行注释掉(重复引入依赖导致错误)
</dependency>