Redisson.create 因 IllegalArgumentException 失败:主机名不能为空

Redisson.create failing with IllegalArgumentException: hostname can't be null

正在尝试使用 Redisson 连接到 Redis(在 Docker 上)...简单的东西..

Config config = new Config(); config.useSingleServer().setAddress("redis://192.168.99.100:6379"); RedissonClient redisson = Redisson.create(config); //第 3 行

但我收到此错误(在第 3 行)- 我是否遗漏了什么?

Exception in thread "main" java.lang.IllegalArgumentException: hostname can't be null at java.net.InetSocketAddress.checkHost(InetSocketAddress.java:149) at java.net.InetSocketAddress.<init>(InetSocketAddress.java:216) at org.redisson.client.RedisClient.<init>(RedisClient.java:105) at org.redisson.connection.MasterSlaveConnectionManager.createClient(MasterSlaveConnectionManager.java:326) at org.redisson.connection.MasterSlaveConnectionManager.createClient(MasterSlaveConnectionManager.java:314) at org.redisson.connection.SingleEntry.setupMasterEntry(SingleEntry.java:47) at org.redisson.connection.MasterSlaveConnectionManager.initEntry(MasterSlaveConnectionManager.java:263) at org.redisson.connection.MasterSlaveConnectionManager.init(MasterSlaveConnectionManager.java:231) at org.redisson.connection.MasterSlaveConnectionManager.<init>(MasterSlaveConnectionManager.java:159) at org.redisson.connection.SingleConnectionManager.<init>(SingleConnectionManager.java:48) at org.redisson.config.ConfigSupport.createConnectionManager(ConfigSupport.java:168) at org.redisson.Redisson.<init>(Redisson.java:111) at org.redisson.Redisson.create(Redisson.java:151)

尝试使用以下代码进行连接:

Config config = new Config();
config.useSingleServer().setAddress("192.168.99.100:6379");
RedissonClient redisson = Redisson.create(config);

使用 config.useSingleServer().setAddress("192.168.99.100:6379") 是解决方案。无需添加 redis://