mac上啟動springboot項目很慢的解決方案


在啟動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項目就變得飛快了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM