在啟動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是什么
~ hostname
han.sun-mac-pro.local
2、查看hosts文件里面配置的是什么
broadcasthost
~ vim /private/etc/hosts 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost
3、復制hostname
127.0.0.1 localhost 你的機器名.local 255.255.255.255 broadcasthost ::1 localhost 你的機器名.local
4、:wq或者:x可能修改不了文件
:w !sudo tee %
5、再去啟動springboot項目就變得飛快了