此版本仍在开发中,尚未被认为是稳定版。请使用最新稳定版 Spring Shell 4.0.1spring-doc.cadn.net.cn

Context Close

命令执行逻辑通过 Spring Boot 的 ApplicationRunner beans 进行。 通常情况下,Spring ApplicationContext 会在这些 runner beans 被处理后自动关闭, 除非有某些东西使其保持活动状态,例如使用了 @EnableScheduling 或者一般来说存在不会自动终止的线程。spring-doc.cadn.net.cn

可以添加配置属性spring.shell.context.close 该属性注册ApplicationListener用于ApplicationReadyEvent,并在Shell执行逻辑完成后请求关闭上下文。spring-doc.cadn.net.cn

spring:
  shell:
    context:
      close: true
此设置默认未启用。