我使用单服务器模式配置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 + "]"));
}
答案 0 :(得分:1)
使用以下配置管理以使其正常工作
Config config = new Config();
config.useSingleServer().setAddress("redis://localhost:6379");