Spring Boot Devtools日志"Starting application"后发生了什么



我试图找出方法来改善我的Spring引导应用程序的重新启动时间,当使用Spring - Boot -devtools时,看到这些日志行之间始终有大约5秒的延迟:

2022-07-03 14:35:28.602 DEBUG 82357 --- [     Thread-165] o.s.boot.devtools.restart.Restarter      : Starting application ...
.   ____          _            __ _ _
/\ / ___'_ __ _ _(_)_ __  __ _    
( ( )___ | '_ | '_| | '_ / _` |    
\/  ___)| |_)| | | | | || (_| |  ) ) ) )
'  |____| .__|_| |_|_| |___, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::                (v2.7.0)
2022-07-03 14:35:33.697  INFO 82357 --- [  restartedMain] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888

我将根日志级别设置为TRACE,但在这5秒内仍然什么也没看到。在这段时间里发生了什么,有没有什么办法可以加快这一进程?

我很幸运,在谷歌上搜索了5秒JVM延迟,发现了潜在的问题,这让我找到了https://github.com/netty/netty/issues/8993

问题和解决方案描述如下:Jvm需要很长时间来解析本地主机的ip地址

这个答案有更多的信息,但简而言之,修复是:

  1. hostname->egMonroes-MacBook-Pro.local
  2. sudo vim /etc/hosts
  3. 添加
127.0.0.1 Monroes-MacBook-Pro.local
::1 Monroes-MacBook-Pro.local

相关页面:

  • https://thoeni.io/post/macos-sierra-java/
  • https://github.com/spring-projects/spring-boot/issues/31572
  • https://github.com/netty/netty/issues/8993
  • Jvm需要很长时间来解析本地主机的ip地址

相关内容

最新更新