gpt4 book ai didi

java - Redisson:无法在单服务器模式下设置地址

转载 作者:可可西里 更新时间:2023-11-01 11:15:32 24 4
gpt4 key购买 nike

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

最佳答案

设法通过使用以下配置让它工作

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

关于java - Redisson:无法在单服务器模式下设置地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49624099/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com