2

I have an issue. Tried to change the versions (like it says on the internet), but it didn't help. I have already read those answers Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry but it didn't help too.

Problem:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter

Console:

***************************
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.autoconfigure.http.HttpMessageConverters.configurePartConverters(HttpMessageConverters.java:140)

The following method did not exist:

    'java.util.List org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.getPartConverters()'

The method's class, org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter, is available from the following locations:

    jar:file:/C:/Users/1/.m2/repository/org/springframework/spring-web/5.2.8.RELEASE/spring-web-5.2.8.RELEASE.jar!/org/springframework/http/converter/support/AllEncompassingFormHttpMessageConverter.class

The class hierarchy was loaded from the following locations:

    org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter: file:/C:/Users/1/.m2/repository/org/springframework/spring-web/5.2.8.RELEASE/spring-web-5.2.8.RELEASE.jar
    org.springframework.http.converter.FormHttpMessageConverter: file:/C:/Users/1/.m2/repository/org/springframework/spring-web/5.2.8.RELEASE/spring-web-5.2.8.RELEASE.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter

My pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example.alpha</groupId>
    <artifactId>bank</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>bank</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>5.2.3.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.2</version>
            <scope>provided</scope>
        </dependency>

            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>2.11.3</version>
            </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
Erwin Bolwidt
  • 30,799
  • 15
  • 56
  • 79
Anastasia
  • 31
  • 1
  • 1
  • 2
  • 1
    Part of Spring Boot's job is to manage dependency versions. You should not include the `version` tags for any of the `dependency` entries in your POM; Boot has already specified the correct ones for you. – chrylis -cautiouslyoptimistic- Jan 05 '21 at 05:40
  • Furthermore spring-boot since 2.4.0 uses JUnit Jupiter only not JUnit 4 anymore so better switch to JUnit Jupiter instead of JUnit 4... Also remove the versions of spring-web as already mentioned....for lombok (really need that?) and for jackson...keep the versions spring-boot offers – khmarbaise Jan 05 '21 at 09:43

2 Answers2

5

As maven is manages the right dependency hierarchy from specified parent project spring-boot-starter-parent for us we do not need to specify the version information anymore for child projects like this <version>5.2.3.RELEASE</version> for below dependency in your case:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>5.2.3.RELEASE</version>
</dependency>
Gopal00005
  • 2,061
  • 4
  • 35
  • 54
3

I solve the problem by adding the Maven dependency below which seems reasonable to be inside pom by default when we download from start.spring.io but it was not there.

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
ali
  • 1,082
  • 1
  • 11
  • 17