23.9 Application退出

为确保ApplicationContext在退出时被平静的(gracefully)关闭,每个SpringApplication都会注册一个JVM的shutdown钩子,所有标准的Spring生命周期回调(比如DisposableBean接口或@PreDestroy注解)都能使用。

此外,如果想在应用结束时返回特定的退出码(exit code),这些beans可以实现org.springframework.boot.ExitCodeGenerator接口。