SpringBoot整合Redis报错:Error creating bean with name ‘redisTemplate‘...NoClassDefFoundError

报错信息:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisTemplate' ... Unsatisfied dependency expressed through method 'redisTemplate' parameter 0;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration.class]: Bean instantiation via factory method failed; 
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory]: Factory method 'redisConnectionFactory' threw exception; 
nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool2/impl/GenericObjectPoolConfig
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.1.11.RELEASE.jar:5.1.11.RELEASE]
	

工程依赖:

SpringBoot2.1.10

报错分析:

1、UnsatisfiedDependencyException 提示缺少依赖

2、java.lang.NoClassDefFoundError: org/apache/commons/pool2/impl/GenericObjectPoolConfig  找不到这个类

解决:

引入依赖:


    org.apache.commons
    commons-pool2
    2.2

搞定

你可能感兴趣的:(issues,record)