SpringBoot 报错:纠正应用程序的类路径,使其包含一个单一的...
最编程
2024-03-23 09:48:54
...
项目场景:
在拉取别人新建的Springboot项目, 出现关于Correct the classpath of your application so that it contains a single, compatible version of xxx错误
错误关键描述如下:
Correct the classpath of your application so that it contains a single, compatible version of org.apache.commons.pool2.impl.GenericObjectPoolConfig
问题描述:
下面是错误的详细描述
2021-03-11 10:00:22.145 ERROR 10196 --- [ 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:
io.lettuce.core.support.CommonsPool2ConfigConverter.bounded(CommonsPool2ConfigConverter.java:49)
The following method did not exist:
org.apache.commons.pool2.impl.GenericObjectPoolConfig.getTestOnCreate()Z
The method's class, org.apache.commons.pool2.impl.GenericObjectPoolConfig, is available from the following locations:
jar:file:/C:/Users/Administrator/.m2/repository/org/apache/commons/commons-pool2/2.0/commons-pool2-2.0.jar!/org/apache/commons/pool2/impl/GenericObjectPoolConfig.class
The class hierarchy was loaded from the following locations:
org.apache.commons.pool2.impl.GenericObjectPoolConfig: file:/C:/Users/Administrator/.m2/repository/org/apache/commons/commons-pool2/2.0/commons-pool2-2.0.jar
org.apache.commons.pool2.impl.BaseObjectPoolConfig: file:/C:/Users/Administrator/.m2/repository/org/apache/commons/commons-pool2/2.0/commons-pool2-2.0.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.apache.commons.pool2.impl.GenericObjectPoolConfig
Process finished with exit code 1
原因分析:
原因是jar版本冲突 ,如springboot starter parent与下面引用的某些启动器或者其他jar版本不一致,导致缓存了多个jar, 而启动时不知道选取哪个版本的jar导致错误
解决方案:
从下图可以看到启动器父版本和子启动器版本不一样, 去除commons-pool2的版本即可