使用IDEA连接远程主机上的Redis失败. 抛出redis.clients.jedis.exceptions.JedisConnectionException: Failed connecting to host xxx
问题: 使用IDEA连接远程主机上的Redis失败. 抛出redis.clients.jedis.exceptions.JedisConnectionException: Failed connecting to host xxx
解决方法: 在Redis的配置文件中注释掉bind
测试代码
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
public class RedisConnectionTest {
public static void main(String[] args) {
JedisPool pool = new JedisPool("192.168.31.169", 6379);
Jedis jedis;
try {
jedis = pool.getResource();
System.out.println(jedis.ping());
} catch (Exception e) {
e.printStackTrace();
}
}
}