上下文关闭

命令执行逻辑通过 Spring Boot 的 ApplicationRunner bean 进行。通常,在这些 runner bean 处理完毕后,Spring ApplicationContext 会自动关闭,除非有某种东西使其保持活动,例如使用 @EnableScheduling 或一般来说存在不会自动终止的线程。

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

spring:
  shell:
    context:
      close: true
此设置默认未启用。
© . This site is unofficial and not affiliated with VMware.