spring_reference/IV. Spring Boot features/22.7. Application exit.md

6 lines
425 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 22.7. Application退出
每个SpringApplication在退出时为了确保ApplicationContext被优雅的关闭将会注册一个JVM的shutdown钩子。所有标准的Spring生命周期回调比如DisposableBean接口或@PreDestroy注解都能使用。
此外如果beans想在应用结束时返回一个特定的退出码exit code可以实现org.springframework.boot.ExitCodeGenerator接口。