码上敲享录 > redis数据库常见问题 > - Bean method 'redisConnectionFactory' not loaded because @ConditionalOnClass did not find required

- Bean method 'redisConnectionFactory' not loaded because @ConditionalOnClass did not find required

上一章章节目录下一章 2019-12-30已有1667人阅读 评论(0)

启动springboot报错信息:

Description:

Parameter 0 of method redisTemplate in org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration$RedisConfiguration required a bean of type 'org.springframework.data.redis.connection.RedisConnectionFactory' that could not be found.


- Bean method 'redisConnectionFactory' not loaded because @ConditionalOnClass did not find required class 'org.apache.commons.pool2.impl.GenericObjectPool'


Action:

Consider revisiting the conditions above or defining a bean of type 'org.springframework.data.redis.connection.RedisConnectionFactory' in your configuration.


我的原因是application.yml配置redis连接的问题,我使用的springboot是高版本的2.1.9,lettuce包含pool,时间要写单位,所以配置如下:

spring:

   redis:

       database: 1 # Redis数据库索引(默认为0)

       host: localhost # Redis服务器地址

       port: 6379 # Redis服务器连接端口

       password:  # Redis服务器连接密码(默认为空)

       lettuce:

         pool:

           max-active: 8 # 连接池最大连接数(使用负值表示没有限制)

           max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)

           max-idle: 8 # 连接池中的最大空闲连接

           min-idle: 0 # 连接池中的最小空闲连接

       timeout: 0ms # 连接超时时间(毫秒)


pom.xml要添加依赖:

<dependency>
     <groupId>org.apache.commons</groupId>
     <artifactId>commons-pool2</artifactId>
</dependency>




向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti
0

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交