type
Post
status
Published
date
Jan 2, 2022
slug
summary
错误信息:InetAddress.getLocalHost().getHostName() took 5005 milliseconds to respond
tags
开发工具
category
Bug 记录
icon
password
SpringBoot 版本 2.4.9,macOS 版本 11.2.3
本地启动时速度慢,几秒后才显示 SpringBoot 的 Banner,并在第一行出现 warn 日志
WARN 63469 --- [main] o.s.boot.StartupInfoLogger: InetAddress.getLocalHost().getHostName() took 5003 milliseconds to respond. Please verify your network configuration (macOS machines may need to add entries to /etc/hosts).
大致原因是,获取本机主机地址时,走到了DNS解析,DNS递归解析不到本机域名,耗时5s
解决方式是将本地回还主机地址添加到 hosts 记录中:
 
hostname #查看本机主机名 vim /private/etc/hosts #打开 hosts 文件 #添加以下机器名到配置中保存 127.0.0.1 localhost ZackYJs-iMac.local 255.255.255.255 broadcasthost ::1 localhost ZackYJs-iMac.local #用 root 权限保存 :w !sudo tee %
:w ! sudo tee %命令:
命令
功能
:w !
执行外部命令
sudo
管理员身份
tee
将标准输入内容写到目标文件
%
vim的一个寄存器,存放vim当前打开的文件名
 
领域模型对象介绍和对比[1]刷机基础知识