博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
阿里云ECS部署spring-boot访问redis出现redis.clients.jedis.HostAndPort - cant resolve localhost address...
阅读量:6408 次
发布时间:2019-06-23

本文共 2580 字,大约阅读时间需要 8 分钟。

问题LOG

2017-08-17 09:06:52.526 [main] ERROR redis.clients.jedis.HostAndPort - cant resolve localhost address

door_1 | java.net.UnknownHostException: iZuf6buf42e89crw6zf: iZuf6buf42e89crw6zf: Name or service not known
door_1 | at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
door_1 | at redis.clients.jedis.HostAndPort.getLocalHostQuietly(HostAndPort.java:105)
door_1 | at redis.clients.jedis.HostAndPort.<clinit>(HostAndPort.java:12)
door_1 | at redis.clients.jedis.JedisFactory.<init>(JedisFactory.java:37)
door_1 | at redis.clients.jedis.JedisPool.<init>(JedisPool.java:185)
door_1 | at redis.clients.jedis.JedisPool.<init>(JedisPool.java:169)
door_1 | at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createRedisPool(JedisConnectionFactory.java:275)
door_1 | at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.createPool(JedisConnectionFactory.java:250)
door_1 | at org.springframework.data.redis.connection.jedis.JedisConnectionFactory.afterPropertiesSet(JedisConnectionFactory.java:237)
door_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
door_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
door_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
door_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
door_1 | at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
door_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
door_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
door_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
door_1 | at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.obtainBeanInstanceFromFactory(ConfigurationClassEnhancer.java:389)
door_1 | at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)

根本原因

这个问题的原因是spring-redis在初始化时会实例化LocalHost,但是ECS的host name并没有在/etc/hosts中设置。

解决方案

在/etc/hosts中设置ECS的host name。类似

127.0.0.1 iZuf6buf42e89crw6zf

转载地址:http://oyaea.baihongyu.com/

你可能感兴趣的文章
版本号带两个小数点的,如何比较大小?( NSStringCompareOptions )
查看>>
HashMap与HashCode
查看>>
QCustomplot使用分享(三) 图
查看>>
什么是java?
查看>>
office等资料下载
查看>>
[LeetCode]题解(python):149-Max Points on a Line
查看>>
WPF路径动画(动态逆向动画)
查看>>
ESXi 主机创建datastore失败
查看>>
day3-函数介绍
查看>>
Low Level Reader Protocol (LLRP) 简介
查看>>
[Micropython]TPYBoard v10x NRF24L01无线通讯模块使用教程
查看>>
mysql中show processlist过滤和杀死线程
查看>>
dxRangeTrackBar使用教程
查看>>
最新Sublime Text 2 激活 汉化
查看>>
spring为什么推荐使用构造器注入
查看>>
C# 使用反射 遍历输出 对象的属性
查看>>
基础数据类型之字典
查看>>
第七次作业
查看>>
Oracle中NVARCHAR2与VARCHAR2的区别
查看>>
php debug
查看>>