上下文關閉
命令執行邏輯透過 Spring Boot 的 ApplicationRunner bean 進行。通常,在這些 runner bean 處理完畢後,Spring ApplicationContext 會自動關閉,除非有某種東西使其保持活動,例如使用 @EnableScheduling 或一般來說存在不會自動終止的執行緒。
可以新增配置屬性 spring.shell.context.close,它會為 ApplicationReadyEvent 註冊 ApplicationListener,並在 shell 完成其執行邏輯後請求關閉上下文。
spring:
shell:
context:
close: true
| 此設定預設未啟用。 |