在启动springboot项目的时候,会停顿好长时间才开始打印日志。
对于强迫症这是受不了的。
查看第一行的日志打印:
InetAddress.getLocalHost().getHostName() took 5004 milliseconds to respond. Please verify your network configuration (macOS machines may need to add entries to /etc/hosts).
这行日志可以看出它去解析hostname的时间就花了5秒多。
这里说明了它去解析了hosts文件:macOS machines may need to add entries to /etc/hosts
解决方案:
1.首先查看本机的hostname是什么

2.复制hostname然后去修改host文件
打开终端进入到本地etc目录下,并修改hosts文件。若存在127.0.0.1 localhost 在此后追加<hostname>.local 即可
非root权限在修改的过程中会出现 45:readonly option is set 等错误,因此在此处直接使用sudo 进行修改,
sudo vim /private/etc/hosts


重新启动idea的项目,变快了:
