【问题标题】:Redisson: Not able to set address in SingleServer modeRedisson:无法在 SingleServer 模式下设置地址
【发布时间】:2018-09-12 10:15:13
【问题描述】:

我是使用单服务器模式配置redis服务器和端口,是不是漏了什么?

Config config = new Config();
config.useSingleServer().setAddress("localhost:6379");

但遇到以下异常

Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in scheme name at index 0: [localhost]:6379
at java.net.URI.create(URI.java:852)
at org.redisson.misc.URIBuilder.create(URIBuilder.java:38)
at org.redisson.config.SingleServerConfig.setAddress(SingleServerConfig.java:129)

org.redisson.misc.URIBuilder中的以下代码似乎有问题

public static URI create(String uri) {
    URI u = URI.create(uri);
    // Let's assuming most of the time it is OK.
    if (u.getHost() != null) {
        return u;
    }
    String s = uri.substring(0, uri.lastIndexOf(":")).replaceFirst("redis://", "").replaceFirst("rediss://", "");
    // Assuming this is an IPv6 format, other situations will be handled by
    // Netty at a later stage.
    return URI.create(uri.replace(s, "[" + s + "]"));
}

【问题讨论】:

    标签: java redis redisson


    【解决方案1】:

    通过使用以下配置使其正常工作

    Config config = new Config();
    config.useSingleServer().setAddress("redis://localhost:6379");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-25
      • 2023-01-17
      • 1970-01-01
      • 2021-06-30
      • 2016-11-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多