java.net.InetAddress.getLocalHost()
错误信息:
InetAddress.getLocalHost().getHostName() took 5002 milliseconds to respond. Please verify your network configuration (macOS machines may need to add entries to /etc/hosts).
这个调用在新版的mac os中可能会耗时很久。
解决办法有两种:
1. 就是把本机的hostname 添加到 hosts 中,例如:
127.0.0.1 localhost 127.0.0.1 loulldeMacBook-Pro.local 255.255.255.255 broadcasthost ::1 localhost ::1 loulldeMacBook-Pro.local
2. 终端中执行
scutil --set HostName "localhost"
大致原因,获取本机地址,走到了DNS解析,DNS递归解析不到本机域名,耗时5s左右
转载:https://www.cnblogs.com/549294286/p/8515351.html