解决springboot 启动 redis连接池问题

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	

这是无法创建redis 连接池的错误,
先看配置和依赖

spring:
  redis:
    database: 0
    host: 127.0.0.1
    lettuce:
      pool:
        max-active: 8
        max-idle: 10
        max-wait: 1ms
        min-idle: 5
      shutdown-timeout: 100ms
    port: 6379
<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-data-redisartifactId>
dependency>

没发现问题

注意错误【nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool2/impl/GenericObjectPoolConfig

由于在yml文件中配置了redis的连接池,而连接池需要一个依赖。
添加连接池依赖


<dependency>
    <groupId>org.apache.commonsgroupId>
    <artifactId>commons-pool2artifactId>
    <version>2.11.1version>
dependency>

你可能感兴趣的:(redis,spring,boot,java)