1.引入依赖

        <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>

2.配置redis相关信息

#密码
spring.redis.password=
spring.redis.cluster.max-redirects=6
#节点信息
spring.redis.cluster.nodes=127.0.0.1:7000,127.0.0.1:7001,127.0.0.1:7002,127.0.0.1:7003,127.0.0.1:7004,127.0.0.1:7005
spring.redis.lettuce.pool.max-idle=16
spring.redis.lettuce.pool.max-active=32
spring.redis.lettuce.pool.min-idle=8

3.测试

    public ImsApplication(RedisTemplate redisTemplate){
redisTemplate.opsForValue().set("spring-r-cluster-1", 123);
redisTemplate.opsForValue().set("spring-r-cluster-2", 456);
redisTemplate.opsForValue().set("spring-r-cluster-3", 789);
redisTemplate.opsForValue().set("spring-r-cluster-4", 321);
redisTemplate.opsForValue().set("spring-r-cluster-5", 654);
redisTemplate.opsForValue().set("spring-r-cluster-6", 987); }

4.测试结果

springboot集成redis集群的更多相关文章

  1. Springboot2.x集成Redis集群模式

    Springboot2.x集成Redis集群模式 说明 Redis集群模式是Redis高可用方案的一种实现方式,通过集群模式可以实现Redis数据多处存储,以及自动的故障转移.如果想了解更多集群模式的 ...

  2. Spring集成Redis集群(含spring集成redis代码)

    代码地址如下:http://www.demodashi.com/demo/11458.html 一.准备工作 安装 Redis 集群 安装参考: http://blog.csdn.net/zk6738 ...

  3. springmvc3.2集成redis集群

    老项目需要集成redis集群 因为spring版本才从2.x升级上来,再升级可能改动较大,且并非maven项目升级麻烦,故直接集成. jar包准备: jedis-2.9.0.jar  -- 据说只有这 ...

  4. springboot+shiro+redis(集群redis版)整合教程

    相关教程: 1. springboot+shiro整合教程 2. springboot+shiro+redis(单机redis版)整合教程 3.springboot+shiro+redis(单机red ...

  5. SpringBoot整合Redis集群

    一.环境搭建 Redis集群环境搭建:https://www.cnblogs.com/zwcry/p/9174233.html 二.Spring整合Redis集群 1.pom.xml <proj ...

  6. SpingBoot之集成Redis集群

    一.安装Redis集群 安装步骤参照网上教程,Mac安装步骤参照https://github.com/muyl/mac-docker-redis-cluster 二.创建SpringBoot工程 创建 ...

  7. springboot和Redis集群版的整合

    此篇接上一个文章springboot和Redis单机版的整合 https://www.cnblogs.com/lin530/p/12019023.html 下面接着介绍和Redis集群版的整合. 1. ...

  8. Spring Boot集成Redis集群(Cluster模式)

    目录 集成jedis 引入依赖 配置绑定 注册 获取redis客户端 使用 验证 集成spring-data-redis 引入依赖 配置绑定 注册 获取redis客户端 使用 验证 异常处理 同样的, ...

  9. springboot基础-redis集群

    一.pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="h ...

随机推荐

  1. XCTF练习题---MISC---stage1

    XCTF练习题---MISC---stage1 flag:AlphaLab 解题步骤: 1.观察题目,下载附件 2.打开附件后发现是一张图片,初步判断是图片隐写,上Stegsolve进行转换,得到一张 ...

  2. python matplotlib在mac os x 中如何显示中文,完美解决

    一. 下载相关的中文字体 simhei 文件: 下载地址 二.通过以下代码查找matplotlib的数据存放位置: import matplotlib print(matplotlib.matplot ...

  3. Linux文本工具-cat-cut-paste;文本分析-sort-wc-uniq

    1.1 查看文本文件内容  cat 1.1.1 cat可以查看文本内容 cat [OPTION]... [FILE]... 常见选项 -E: 显示行结束符$ -A: 显示所有控制符 -n: 对显示出的 ...

  4. SpringJdbcTemplate简单实现

    SpringJdbcTemplate 配置文件 1.依赖坐标 <dependencies> <dependency> <groupId>javax.servlet& ...

  5. C#实现登录功能(连接SQLServer数据库)

    本例使用C#实现一个简单的登录功能,分为用户和管理员两个角色登录. 效果图: 核心代码 login.cs private void button1_Click(object sender, Event ...

  6. Vue路由实现之通过URL中的hash(#号)来实现不同页面之间的切换(图表展示、案例分析、附源码详解)

    前言 本篇随笔主要写了Vue框架中路由的基本概念.路由对象属性.vue-router插件的基本使用效果展示.案例分析.原理图解.附源码地址获取. 作为自己对Vue路由进行页面跳转效果知识的总结与笔记. ...

  7. 值得注意的: c++动态库、静态库、弱符号__attribute__((weak))以及extern之间的关系

    先说结论: ①:动态库优先级最差,如果同时有静态库和动态库,那么首先使用的是静态库函数. ②:如果只有两个或多个动态库,那么首先使用的是最开始链接的动态库函数: ③:弱符号函数在动态库中是起任何作用的 ...

  8. javaweb开发案例

    1.实验3 (1)当运行Servlet时,碰到"空指针异常"错误怎么处理? 答:应提示用户操作有误,或设置对象值为空字符串或一个默认值,或是不执行某操作,直接跳转到其他处理中. ( ...

  9. asp.net core系列 77 webapi响应压缩

    一.介绍 背景:目前在开发一个爬虫框架,使用了.net core webapi接口作为爬虫调用入口,在调用 webapi时发现爬虫耗时很短(1秒左右),但客户端获取响应时间却在3~4秒.对于这个问题考 ...

  10. 工具分享:清理 Markdown 中没有引用的图片

    前言: 之前,我写笔记的工具一直都是 notion,而且没有写博客的习惯.但是一是由于 notion 的服务器在国外,有时候很不稳定:二是由于 notion 的分享很不方便,把笔记分享给别人点开链接之 ...