项目场景:
场景:后台服务请求超时,普通接口两三分钟才返回
服务启动时报错InetAddress.getLocalHost().getHostName() took 20019 milliseconds to respond. Please verify your network configuration
org.springframework.boot.StartupInfoLogger - InetAddress.getLocalHost().getHostName() took 20019 milliseconds to respond. Please verify your network configuration
问题描述
org.springframework.boot.StartupInfoLogger - InetAddress.getLocalHost().getHostName() took 20019 milliseconds to respond. Please verify your network configuration
原因分析:
问题是启动时获取 hostname 耗时时间较长
在服务器上执行 hostname 查看
查看 /etc/hosts 文件内容
解决方案:
发现配置文件中并无 hostname 配置信息(虚拟机安装后,更改过 hostname),将 hostname 添加到 /etc/hosts 配置中,如下所示
或者将hostname加到127.0.0.1后面
即可解决 hostname 获取导致的服务启动较慢问题