相关疑难解决方法(0)

如何以正确的方式关闭Spring Boot应用程序?

在Spring Boot Document中,他们说'每个SpringApplication都会向JVM注册一个关闭钩子,以确保在退出时优雅地关闭ApplicationContext.

当我单击ctrl+cshell命令时,可以正常关闭应用程序.如果我在生产机器中运行应用程序,我必须使用该命令 java -jar ProApplicaton.jar.但是我无法关闭shell终端,否则会关闭进程.

如果我运行命令nohup java -jar ProApplicaton.jar &,我不能使用ctrl+c优雅地关闭它.

在生产环境中启动和停止Spring Boot应用程序的正确方法是什么?

linux spring spring-boot

97
推荐指数
10
解决办法
13万
查看次数

如何在启动期间终止 Spring 应用程序?

我有一个 Spring Boot 应用程序,它具有一些外部依赖项(例如,项目外部的文件需要存在才能使应用程序正常启动)。

我的一个 bean 有一个@PostConstruct进行初始化的方法。如果初始化不成功,我想干净优雅地退出 - 例如,找不到文件。

调用((ConfigurableApplicationContext)applicationContext).close();@PostConstruct方法会导致

java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context
Run Code Online (Sandbox Code Playgroud)

以及一系列其他异常。有没有办法正确地做到这一点?

spring spring-boot

5
推荐指数
1
解决办法
1612
查看次数

标签 统计

spring ×2

spring-boot ×2

linux ×1