Redisson.create失败并出现IllegalArgumentException:hostname不能为null

时间:2017-06-13 12:43:34

标签: redis redisson

尝试使用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)

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

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

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