1

我正在使用单服务器模式来配置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 + "]"));
}
4

1 回答 1

1

通过使用以下配置管理使其工作

Config config = new Config();
config.useSingleServer().setAddress("redis://localhost:6379");
于 2018-04-03T07:21:06.413 回答