【问题标题】:Spring boot shut down application gracefullySpring Boot 优雅地关闭应用程序
【发布时间】:2021-10-28 22:17:35
【问题描述】:

优雅关闭spring boot应用程序的最佳方法是什么(Spring boot - 2.4.9版本)?

我应该注册关闭挂钩吗? applicationContext.registerShutdownHook();

以下就足够了吗?我理解下面确实会优雅地关闭容器 System.exit(SpringApplication.exit(appContext, () -> 0));

【问题讨论】:

标签: spring spring-boot


【解决方案1】:

在 intellij 中,如果您使用 spring-boot:run 启动它,那么您可以在终端窗口中使用 CTRL + C 将其关闭

【讨论】:

    猜你喜欢
    • 2016-06-09
    • 2016-06-17
    • 1970-01-01
    • 2019-09-26
    • 1970-01-01
    • 1970-01-01
    • 2019-02-23
    • 1970-01-01
    相关资源
    最近更新 更多