查看第一行的日志打印:
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
- 查看本机的hostname是什么:
~ hostname
han.sun-mac-pro.local
- 编辑hosts文件:
~ vim /private/etc/hosts
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
复制hostname,改为:
127.0.0.1 localhost 你的机器名.local
255.255.255.255 broadcasthost
::1 localhost 你的机器名.local
就可以了
本文转载自mac上启动springboot项目很慢的解决方案并有精简