跳到主要内容

上下文关闭

ChatGPT-4o-mini 中英对照 Context Close

命令执行逻辑通过 Spring Boot 的 ApplicationRunner beans 进行。通常情况下,Spring ApplicationContext 在这些 runner beans 被处理后会自动关闭,除非有一些东西使其保持活跃,比如使用 @EnableScheduling,或者一般来说,有一些线程不会自动结束。

可以添加配置属性 spring.shell.context.close,该属性注册 ApplicationListener 以监听 ApplicationReadyEvent,并在 shell 完成其执行逻辑后请求关闭上下文。

spring:
shell:
context:
close: true
yaml
备注

此设置默认情况下未启用。