spring-boot - 在 spring-data-redis 中定义集群节点属性的替代方法

标签 spring-boot spring-data-redis missing-features

我试图在我的项目中使用 spring-data-redis 。当我在 yaml 文件中配置 redis 节点时,如下所示:

spring:
  redis:
    cluster:
      max-redirects: 2
      nodes: host1:6379,host1:6380,host1:6381

然后,spring-data-redis在内部创建集群的JedisConnectionFactory。但是如果我尝试通过以下方式配置:

spring:
  redis:
    cluster:
      max-redirects: 2
      nodes: 
        - host1:6379
        - host1:6380
        - host1:6381

然后,我必须在我的应用程序中为集群创建 JedisConnectionFactory 的 bean。

我猜当前版本的 spring-data-redis 不支持在 yaml 中以数组方式表示节点数量来创建集群。

我的建议是spring-boot/spring-data-redis开发者可以支持上述格式的yaml来内部创建redis集群吗?

最佳答案

如果您检查here ,可以像这样将 hostAndPort 作为一个丑陋的数组提供,与 spring.redis 属性组分开;

clusterHostAndPorts:
  - host1:6379
  - host1:6380
  - host1:6381

在我本地测试过,确实有效,不支持你问的方式,可以看看here ,然后 here ,最后 here .

HostAndPort need to be seperated by ':'.

Host and Port String needs to specified as host:port

关于spring-boot - 在 spring-data-redis 中定义集群节点属性的替代方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42967518/

相关文章:

java - Spring Boot 不断使我的电脑崩溃...Windows 10 上 sts.ini 文件的最佳配置是什么?

redis - 使用 lfu 收集 redis 热键频率

java - StringRedisTemplate 与 StringRedisConnection

android-studio - Android Studio 3.1.3 中缺少 LogCat

python - 在没有 math.ceil() 的情况下向上舍入数学计算?

java - @Document 中的 HashSet,其中实体使用唯一 ID,DuplicatekeyException

java - 我可以在 Spring boot 应用程序中使用 Spring 集成模块吗?

Java 创建一个 api 来公开 csv 而不是 json

通过具有过去时间戳的 EXPIREAT 命令的 Redis key 过期事件

asp.net - Global.asax 模板在 Visual Studio 中不可用