23.9 Application exit
Each SpringApplication
will register a shutdown hook with the JVM to ensure that the ApplicationContext
is closed gracefully on exit. All the standard Spring lifecycle callbacks (such as the DisposableBean
interface, or the @PreDestroy
annotation) can be used.
In addition, beans may implement the org.springframework.boot.ExitCodeGenerator
interface if they wish to return a specific exit code when the application ends.