Home > Software engineering >  Conflict problem building the Spring boot
Conflict problem building the Spring boot

Time:05-12

I have a problem building the spring boot application. We need to build the project with the 'lib/bin/conf' structure using the maven. I did it with another project and there is no problem. But now, a conflict occurred and an action is recommended.

***************************
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.beans.factory.support.DefaultSingletonBeanRegistry.<init>(DefaultSingletonBeanRegistry.java:88)

The following method did not exist:

    'java.util.Map org.springframework.core.CollectionFactory.createConcurrentMapIfPossible(int)'

The calling method's class, org.springframework.beans.factory.support.DefaultSingletonBeanRegistry, is available from the following locations:

    jar:file:/Users/user/.m2/repository/org/springframework/spring/2.5.5/spring-2.5.5.jar!/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.class
    jar:file:/Users/user/.m2/repository/org/springframework/spring-beans/5.3.18/spring-beans-5.3.18.jar!/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.class

The calling method's class was loaded from the following location:

    file:/Users/user/.m2/repository/org/springframework/spring/2.5.5/spring-2.5.5.jar

The called method's class, org.springframework.core.CollectionFactory, is available from the following locations:

    jar:file:/Users/user/.m2/repository/org/springframework/spring-core/5.3.18/spring-core-5.3.18.jar!/org/springframework/core/CollectionFactory.class
    jar:file:/Users/user/.m2/repository/org/springframework/spring/2.5.5/spring-2.5.5.jar!/org/springframework/core/CollectionFactory.class

The called method's class hierarchy was loaded from the following locations:

    org.springframework.core.CollectionFactory: file:/Users/user/.m2/repository/org/springframework/spring-core/5.3.18/spring-core-5.3.18.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.beans.factory.support.DefaultSingletonBeanRegistry and org.springframework.core.CollectionFactory


How can I solve this problem? Some of the libraries provided by the company have been deleted. This is my pom file.

<?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.6.6</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>...</groupId>
    <artifactId>...</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>...</name>

    <properties>
        <java.version>11</java.version>
        <finalName>${project.artifactId}-${project.version}</finalName>
        <logback.version>1.2.9</logback.version>
        <log4j.version>2.17.0</log4j.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-batch</artifactId>
        </dependency>
        <dependency>
            <groupId>net.javacrumbs.shedlock</groupId>
            <artifactId>shedlock-spring</artifactId>
            <version>4.34.0</version>
        </dependency>
        <dependency>
            <groupId>net.javacrumbs.shedlock</groupId>
            <artifactId>shedlock-provider-jdbc-template</artifactId>
            <version>4.34.0</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- vault -->
        <dependency>
            <groupId>org.springframework.vault</groupId>
            <artifactId>spring-vault-core</artifactId>
            <version>2.2.2.RELEASE</version>
        </dependency>

        <!-- log4j -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j.version}</version>
        </dependency>

        <!-- logback -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>${logback.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>

        <!-- Swagger 2 -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>

        <!-- Apache Commons -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.11</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.8.0</version>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.4</version>
        </dependency>

        <dependency>
            <groupId>io.lettuce</groupId>
            <artifactId>lettuce-core</artifactId>
            <version>5.2.2.RELEASE</version>
        </dependency>

        <!--proxy-->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.13</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>${finalName}</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

CodePudding user response:

Spring 2.5.5 has been obsolete for 12 years; there's no reason for you to have it. Furthermore, it makes absolutely no sense whatsoever to have a lib directory with Maven; dependency management is much of what Maven is for.

I see nothing in your POM that would pull in Spring 2.5.5. Is it possible that something else related to your project made a typo and intended to include Spring Boot 2.5.5? In any case, determine where this is coming from (mvn dependency:tree) and fix that.

CodePudding user response:

DefaultSingletonBeanRegistry and CollectionFactory are duplicate in spring-2.5.5, actually they are already included in spring-beans and spring-core.

Execute 'mvn dependency:tree -Dverbose' to see how spring-2.5.5 is included, exclude it and try again

  • Related