Factory method 'redisConnectionFactory' threw exception; nested exception is java.lang.NoClassDefFou

springBoot 项目使用redis缓存,项目启动报错:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authController': 
Unsatisfied dependency expressed through field 'authService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'authService': Unsatisfied dependency expressed through field 'redisTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'stringRedisTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.class]: 
Unsatisfied dependency expressed through method 'stringRedisTemplate' 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

报错原因: java.lang.NoClassDefFoundError: org/apache/commons/pool2/impl/GenericObjectPoolConfig
故加入依赖commons-pool2即可:

		
            org.apache.commons
            commons-pool2
        

commons-pool2:对象池依赖,从名字可知其大概作用,其深层次东西暂未研究,只知道springBoot这里用redis需要加入该依赖;若有乱用的情况,还请指出;

你可能感兴趣的:(springBoot)