springboot 整合redis部署出现 redis.clients.jedis.HostAndPort - cant resolve localhost address错误

springboot 整合redis部署出现 redis.clients.jedis.HostAndPort - cant resolve localhost address错误

redis.clients.jedis.HostAndPort - cant resolve localhost address

解决方案:http://www.leftso.com/blog/248.html

Java连接redis启动报错Error redis clients jedis HostAndPort cant resolve localhost address

问题描述

错误环境:
本地window开发环境没有问题。上到Linux环境,启动出现问题。
错误信息:
Error redis clients jedis HostAndPort cant resolve localhost address

07-Aug-2017 15:44:52.529 SEVERE [localhost-startStop-1] redis.clients.jedis.HostAndPort.getLocalHostQuietly cant resolve localhost address
 java.net.UnknownHostException: template: template: Name or service not known
    at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
    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 org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createRedisPool(JedisConnectionFactory.java:227)

问题解决

解决办法:

  • 1.查看Linux系统的主机名
[root@template conf]# hostname
DSWX
[root@template conf]# 

2.查看/etc/hosts文件中是否有127.0.0.1对应主机名,如果没有则添加 DSWX

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 DSWX
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

再次启动即可.

你可能感兴趣的:(项目上线那些事)