Spring第一个请求很慢 [英] Spring first request very slow
本文介绍了Spring第一个请求很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Spring Boot 中有应用程序.用内嵌的tomcat初始化Spring Boot后,第一次响应很慢.我该如何解决?spring boot 有任何预热命令/模式吗?我也在考虑与数据库的连接,我想知道连接数据库,可能在第一次请求期间 spring 与 Postgres 连接.
I have application in Spring Boot. After initialization of Spring Boot with embeded tomcat, the first response is very slow. How can I fix it? Has spring boot any warmup command/mode? I am thinking too about connection with database and I am wondering about connection database, probably spring connects with Postgres during first request.
推荐答案
你可以使用 ApplicationRunner 或 CommandlineRunner 在启动时运行一些东西:
You could either use ApplicationRunner or CommandlineRunner to run something on startup:
这篇关于Spring第一个请求很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文