项目场景:
新建spingboot项目启动报错
问题描述:
报错信息
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.boot.autoconfigure.http.HttpMessageConverters.configurePartConverters(HttpMessageConverters.java:140)
The following method did not exist:
org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.getPartConverters()Ljava/util/List;
The method's class, org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter, is available from the following locations:
jar:file:/E:/apache-maven-3.6.3/repository/org/springframework/spring-web/5.2.9.RELEASE/spring-web-5.2.9.RELEASE.jar!/org/springframeworktp/converter/support/AllEncompassingFormHttpMessageConverter.class
The class hierarchy was loaded from the following locations:
org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter: file:/E:/apache-maven-3.6.3/repository/org/springframework/spring-web/5.2.9.RELEASE/spring-web-5.2.9.RELEASE.jar
org.springframework.http.converter.FormHttpMessageConverter: file:/E:/apache-maven-3.6.3/repository/org/springframework/spring-web/5.2.9.RELEASE/spring-web-5.2.9.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter
Process finished with exit code 1
原因分析:
maven依赖导错
- 错误的依赖
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
- 正确的依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>