Java学习-085-Springboot 解决 InetAddress.getLocalHost().getHostName() took 13387 milliseconds to respond. Please verify your network configuration

在启动 Springboot 时,发现启动耗时较长,启动日志提示:InetAddress.getLocalHost().getHostName() took 13387 milliseconds to respond. Please verify your network configuration

问题是启动时获取 hostname 耗时时间较长,

在服务器上执行 hostname 查看

 

查看 /etc/hosts 文件内容如下:

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

 

 发现配置文件中并无 hostname 配置信息(虚拟机安装后,更改过 hostname),将 hostname 添加到 /etc/hosts 配置中,如下所示:

127.0.0.1   localhost fanfengping.com localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost fanfengping.com localhost.localdomain localhost6 localhost6.localdomain6

 

重启服务,即可解决 hostname 获取导致的服务启动较慢问题。

 

posted @ 2022-02-19 17:26  范丰平  Views(3337)  Comments(0Edit  收藏  举报