springboot中各个版本的redis配置问题
今天在springboot中使用数据库,springboot版本为2.0.2.RELEASE,通过pom引入jar包,配置文件application.properties中的redis配置文件报错,提示例如deprecated configuration property 'spring.redis.pool.max-active',猜想应该是版本不对,发现springboot在1.4前后集成redis发生了一些变化。下面截图看下。
一、不同版本RedisProperties的区别
这是springboot版本为1.3.2RELEASE中的RedisProperties配置文件类,从图片中可以看得出来该本的redis配置文件属性有两个内部静态类分别是Pool和Sentinel,七个属性变量。例如我们想在配置文件中设置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以下
-
<!--引入 spring-boot-starter-redis(1.4版本前)-->
-
<dependency>
-
<groupId>org.springframework.boot</groupId>
-
<artifactId>spring-boot-starter-redis</artifactId>
-
<version>1.3.2.RELEASE</version>
-
</dependency>
springboot版本1.4以上
<!--引入 spring-boot-starter-data-redis(1.4版本后)多了个data加个红和粗吧-->
-
<dependency>
-
<groupId>org.springframework.boot</groupId>
-
<artifactId>spring-boot-starter-data-redis</artifactId>
-
</dependency>
原文地址:https://blog.csdn.net/qq_33326449/article/details/80457571
springboot中各个版本的redis配置问题的更多相关文章
- SpringBoot中Shiro缓存使用Redis、Ehcache
在SpringBoot中Shiro缓存使用Redis.Ehcache实现的两种方式实例 SpringBoot 中配置redis作为session 缓存器. 让shiro引用 本文是建立在你是使用这sh ...
- springboot中使用cache和redis
知识点:springboot中使用cache和redis (1)springboot中,整合了cache,我们只需要,在入口类上加 @EnableCaching 即可开启缓存 例如:在service层 ...
- 在SpringBoot中存放session到Redis
前言 今天你们将再一次领略到SpringBoot的开发到底有多快,以及SpringBoot的思想(默认配置) 我们将使用redis存放用户的session,用户session存放策略有很多,有存放到内 ...
- springboot 中 集成druid ,redis
1,导入druid jar包 <!--引入drud--> <dependency> <groupId>com.alibaba</groupId> < ...
- springboot中,使用redisTemplate操作redis
知识点: springboot中整合redis springboot中redisTemplate的使用 redis存数据时,key出现乱码问题 一:springboot中整合redis (1)pom. ...
- SpringBoot中整合Redis、Ehcache使用配置切换 并且整合到Shiro中
在SpringBoot中Shiro缓存使用Redis.Ehcache实现的两种方式实例 SpringBoot 中配置redis作为session 缓存器. 让shiro引用 本文是建立在你是使用这sh ...
- 实例讲解Springboot以Repository方式整合Redis
1 简介 Redis是高性能的NoSQL数据库,经常作为缓存流行于各大互联网架构中.本文将介绍如何在Springboot中整合Spring Data Redis,使用Repository的方式操作. ...
- 你知道如何在springboot中使用redis吗
特别说明:本文针对的是新版 spring boot 2.1.3,其 spring data 依赖为 spring-boot-starter-data-redis,且其默认连接池为 lettuce ...
- (二)Redis在Mac下的安装与SpringBoot中的配置
1 下载Redis 官网下载,下载 stable 版本,稳定版本. 2 本地安装 解压:tar zxvf redis-6.0.1.tar.gz 移动到: sudo mv redis-6.0.1 /us ...
随机推荐
- console 中的格式化打印(占位符),和样式定义
格式化打印 Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6) 首次发布对string substitutions的支持.你可以在传递给 ...
- R语言因子
R语言因子 因子是它们用于将数据进行分类并将其存储为级别的数据对象.它们可以同时存储字符串和整数.它们在具有唯一值的有限数目的列是有用的. 例如,"male, "Female&qu ...
- Web.xml详解(转)(Filter,context,listener)
web.xml 详细解释!!(链接) web.xml加载过程(步骤) 首先简单说一下,web.xml的加载过程. 当我们去启动一个WEB项目时,容器包括(JBoss.Tomcat等)首先会读取项目we ...
- node服务器的配置
安装node 安装pm2 http://blog.csdn.net/chenlinIT/article/details/73343793 安装mongodbhttp://zixuephp.net/ar ...
- Error configuring application listener of class org.springframework.web.context.ContextLoaderListene 标签: tomcat
今天敲完ssm框架,启动tomcat时报了这个错误.如图: SEVERE: Error configuring application listener of class org.springfram ...
- More Effective C++: 04效率
16:牢记80-20准则 80-20准则说的是大约20%的代码使用了80%的程序资源:大约20%的代码耗用了大约80%的运行时间:大约20%的代码使用了80%的内存:大约20%的代码执行80%的磁盘访 ...
- PHP:测试SQL注入以及防止SQL注入
在写登录注册的时候发现了SQL和JS注入这个危害网站的用户举动: 测试方法: SQL注入: 先来做一个测试: 用户名:’ or 1 # 密码:随便写8位以上 验证码:写正确 好吧,就那么简单就进去了: ...
- 集合--Map&&HasMap和TreeMap
特点:以键值对key,value方式存储的结构 key:Set集合 key能重复,无序的,如果重复,后面的key会把前面的覆盖掉(key必须是唯一的,不唯一,那么后面的value会把前面的va ...
- Python中基于socketserver实现并发的socket
1.基于TCP协议: 服务端: import socketserver class MyHandler(socketserver.BaseRequestHandler): def handle(sel ...
- CAD安装失败怎样卸载重新安装CAD,解决CAD安装失败的方法总结
技术帖:CAD没有按照正确方式卸载,导致CAD安装失败.楼主也查过网上关于如何解决CAD安装失败的一些文章,是说删除几个CAD文件和CAD软件注册表就可以解决CAD安装失败的问题,实际的情况并没有这么 ...