Context Close
命令執行邏輯透過 Spring Boot 的 ApplicationRunner
beans 發生。正常情況下,Spring ApplicationContext
會在這些 runner beans 處理完畢後自動關閉,除非有某些東西使其保持運作,例如使用 @EnableScheduling
,或者更廣泛地說,存在不會自動終止的執行緒。
可以新增組態屬性 spring.shell.context.close
,它會為 ApplicationReadyEvent
註冊 ApplicationListener
,並在 shell 完成其執行邏輯後請求關閉 context。
spring:
shell:
context:
close: true
此設定預設為停用。 |