问题:
使用java连接Linux服务器上的redis失败
代码:
package com.redis.study.test;
import org.junit.Test;
import redis.clients.jedis.Jedis;
public class RedisTest {
@Test
public void test() {
Jedis jedis = new Jedis("192.168.80.128", 6379);
System.out.println(jedis.get("username"));
}
}
错误日志:
redis.clients.jedis.exceptions.JedisConnectionException: Failed connecting to host 192.168.80.128:6379
at redis.clients.jedis.Connection.connect(Connection.java:207)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:93)
at redis.clients.jedis.Connection.sendCommand(Connection.java:126)
at redis.clients.jedis.Connection.sendCommand(Connection.java:117)
at redis.clients.jedis.Jedis.get(Jedis.java:152)
at com.redis.study.test.RedisTest.test(RedisTest.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.interna