spring boot集成Redis Sentinel(哨兵模式)

本文详细介绍了如何在Spring Boot应用中集成Redis Sentinel,包括在pom.xml中添加依赖,创建redis.properties配置文件,以及编写RedisConfig配置类,设置连接池、哨兵配置和RedisTemplate。最后总结了集成步骤。
摘要由CSDN通过智能技术生成

1、在pom.xml文件中添加依赖:

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-redis</artifactId>

<version>1.4.7.RELEASE</version>

</dependency>

 

2、创建resources/config/redis.properties配置文件

redis.properties文件内容如下:

#哨兵模式

#多个使用,分隔

redis.nodes=10.135.16.164:26379

redis.masterName=GMDCEQ-dev

redis.password=Haier,123

redis.maxTotal=10000

redis.maxIdle=100

redis.minIdle=50

redis.timeout=30000

 

3、创建RedisConfig.java,redis的配置类

package com.haier.gmdc.biprodweb.redisservice;

 

import com.fasterxml.jackson.annotation.JsonAutoDetect;

import com.fasterxml.jackson.annotation.PropertyAccessor;

import com.fasterxml.jackson.databind.ObjectMapper;

import org.springframework.beans.factory.annotation.Qualifier;

import org.springframework.beans.factory.annotation.Value;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import org.springframework.context.annotation.PropertySource;

import org.springframework.data.redis.connection.RedisNode;

import org.springframe

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值