spring-cloud 上下文 bootstrap 忽略主上下文中禁用的 spring 关闭挂钩

spring-cloud context bootstrap ignores disabled spring shutdown hook in main context

我们正在实施自己的关闭挂钩,并希望禁用 spring 附带的默认设置。它在 spring 不使用 spring-cloud 的应用程序中运行良好。

SpringApplication app = new SpringApplicationBuilder(NoaApp.class).build();
app.setRegisterShutdownHook(false);
ConfigurableApplicationContext applicationContext = app.run(args);
GracefulShutdownHook.register(applicationContext);

SpringApplication 触发一个事件,该事件导致 BootstrapApplicationListener 初始化一个新的上下文,其中 registerShutdownHook 标志设置为默认值 true,这会注册关闭挂钩。

有没有一种干净的方法来解决这个问题?

我们在 spring-cloud 1.0.3 上,已在 1.1.0 版中修复