有两种整合方法:
1.第一种:在yml配置文件中进行配置:(最后六行)
spring:
redis:
host: 192.168.43.196
port: 6380
password: 123456
database: 0
timeout: 10000ms
lettuce:
pool:
max-active: 1024
max-wait: 10000ms
max-idle: 200
min-idle: 5
#哨兵模式
sentinel:
#主节点名称
master: master
#节点
nodes: 192.168.43.196:26379,192.168.43.196:26380,192.168.43.196:26381
2.第二种:在config配置类中配置:
@Bean
public RedisSentinelConfiguration redisSentinelConfiguration(){
RedisSentinelConfiguration redisSentinelConfiguration =
new RedisSentinelConfiguration()
.master("master")
.sentinel("192.168.43.196",26379)
.sentinel("192.168.43.196",26380)
.sentinel("192.168.43.196",26381);
redisSentinelConfiguration.setPassword("123456");
return redisSentinelConfiguration;
}