构建Spring引导的冲突问题



我在构建spring引导应用程序时遇到了问题。我们需要使用maven构建带有'lib/bin/conf'结构的项目。我在另一个项目中也这样做过,没有问题。但是现在,发生了冲突,建议采取行动。

***************************
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

我该如何解决这个问题?该公司提供的一些库已被删除。这是我的文件。

<?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>

Spring 2.5.5已经过时12年了;你没有理由拥有它。此外,在Maven中使用lib目录绝对没有任何意义;依赖管理在很大程度上是Maven对于的作用。

我在你的POM中看不到任何会在Spring 2.5.5中拉的东西。是否有可能是其他与您的项目相关的东西打错了,并打算包括SpringBoot2.5.5吗?在任何情况下,确定它来自哪里(mvn dependency:tree)并修复它。

DefaultSingletonBeanRegistry和CollectionFactory在spring-2.5.5中是重复的,实际上它们已经包含在spring-beans和spring-core中。

执行'mvn dependency:tree -Dverbose'查看spring-2.5.5是如何包含的,排除它,然后再试一次

最新更新