Linux下使用RedisPool時報錯:redis.clients.jedis.HostAndPort getLocalHostQuietly 嚴重: cant resolve localhost

一月 24, 2018 10:45:46 上午 redis.clients.jedis.HostAndPort getLocalHostQuietly 嚴重: cant resolve localhost address java.net.UnknownHostException: centos7: centos7: 域名解析暫時失敗 at java.net.InetAddress.getLocalHost(InetAddress.java:1475) at redis.clients.jedis.HostAndPort.getLocalHostQuietly(HostAndPort.java:105) at redis.clients.jedis.HostAndPort.<clinit>(HostAndPort.java:12) at redis.clients.jedis.JedisFactory.<init>(JedisFactory.java:37) at redis.clients.jedis.JedisPool.<init>(JedisPool.java:185) at redis.clients.jedis.JedisPool.<init>(JedisPool.java:162) at redis.clients.jedis.JedisPool.<init>(JedisPool.java:92) at com.test.redis.JedisUtil.<clinit>(JedisUtil.java:18) at com.test.redis.JedisPoolTest.test(JedisPoolTest.java:10) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: java.net.UnknownHostException: centos7: 域名解析暫時失敗 at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1295) at java.net.InetAddress.getLocalHost(InetAddress.java:1471) ... 30 more

解決方案:java

$ hostname  ##查看主機名redis

 

$ vim /etc/hosts  ##查看主機名是否包含在第一行中,若無,添加便可vim

OKcentos

 

 

 

 

查看eclipse

相關文章
相關標籤/搜索