springboot中各个品牌的redis驱动问题版权声明

原创
小哥 3年前 (2022-10-27) 阅读数 36 #大杂烩

今天在springboot使用中的数据库,springboot版本为2.0.2.RELEASE,通过pom引入jar包,配置文件application.properties中的redis配置文件报告了一个错误,例如提示deprecated configuration property spring.redis.pool.max-active,猜测应该是版本错误,找到了springboot在1.4前后集成redis已经发生了一些变化。请看下面的屏幕截图。

1.不同版本RedisProperties的区别
这是springboot版本为1.3.2RELEASE中的RedisProperties从图中可以看到配置文件类。redis配置文件属性有两个内部静态类,分别是Pool和Sentinel、7个属性变量。例如,我们想要在配置文件中设置。redis数据库host地址,你可以这样写。

spring.redis.host=localhost    host为属性,配置到连接池的最大连接数。 spring.redis.pool.max-active=8

这个是redis在application.properties中springboot较低版本配置

REDIS (RedisProperties)

Redis数据库索引(默认0)

spring.redis.database=0

Redis服务器地址

spring.redis.host=localhost

Redis服务器连接端口

spring.redis.port=6379

Redis服务器连接密码(默认情况下为空)

spring.redis.password=

连接池中的最大连接数(负值表示没有限制)

spring.redis.pool.max-active=8

连接池的最大阻塞等待时间(负值表示没有限制)

spring.redis.pool.max-wait=-1

连接池中的最大空闲连接数数

spring.redis.pool.max-idle=8

连接池中的最小空闲连接数数

spring.redis.pool.min-idle=0

连接超时(毫秒)

spring.redis.timeout=0

下图则是springboot版本为2.0.2RELEASE中的RedisProperties配置文件类,如图所示。pool该属性封装在内部静态类中。Jedis和Lettuce中去了,这时我们要是配置到连接池的最大连接数。,前缀还是spring.redis,有两种方法

spring.redis.jedis.pool.max-active=8  或者 spring.redis.lettuce.pool.max-active=8

这个是redis在application.properties中springboot高版本配置

REDIS (RedisProperties)

Redis数据库索引(默认0)

spring.redis.database=0

Redis服务器地址

spring.redis.host=localhost

Redis服务器连接端口

spring.redis.port=6379

Redis服务器连接密码(默认情况下为空)

spring.redis.password=

连接池中的最大连接数(负值表示没有限制)

spring.redis.jedis.pool.max-active=8

连接池的最大阻塞等待时间(负值表示没有限制)

spring.redis.jedis.pool.max-wait=-1

连接池中的最大空闲连接数数

spring.redis.jedis.pool.max-idle=8

连接池中的最小空闲连接数数

spring.redis.jedis.pool.min-idle=0

连接超时(毫秒)

spring.redis.timeout=0
2、maven下pom坐标配置在
springboot版本1.4以下

org.springframework.boot spring-boot-starter-redis 1.3.2.RELEASE springboot版本1.4以上 org.springframework.boot spring-boot-starter-data-redis

————————————————
版权声明:本文是CSDN博客作者《孤独的秋风》的原文如下 CC 4.0 BY-SA 版权协议,转载请附上原始来源链接和本声明。
原始链接:https://blog.csdn.net/qq\_33326449/article/details/80457571

版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除

热门