问题说明:在工程中引入了jedis包后同时带入了commons-pool2的包,结果在调用某个业务时报出如下错误:
java.lang.NoClassDefFoundError: org/apache/commons/pool/KeyedPoolableObjectFactory
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2688)
at java.lang.Class.getDeclaredMethods(Class.java:1962)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:570)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:489)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:473)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:241)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1059)
at
....
查看mvn dependency:tree后,发现有两个版本的pool包:
[INFO] | | +- mysql:mysql-connector-java:jar:5.1.10:compile
[INFO] | | +- <span style="color:#cc6600;">commons-pool:commons-pool:jar:1.6:compile</span>
[INFO] \- redis.clients:jedis:jar:2.7.2:compile
[INFO] \-<span style="color:#cc6600;"> org.apache.commons:commons-pool2:jar:2.3:compile</span>
单独引入1.6版本,问题解决。