Spring Boot shutdown hook

后端 未结 4 2091
醉话见心
醉话见心 2020-12-05 12:59

How can I register/add a custom shutdown routine that shall fire when my Spring Boot application shuts down?

Scenario: I deploy my Spring Boot application to a Jetty

4条回答
  •  囚心锁ツ
    2020-12-05 13:35

    http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-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.

提交回复
热议问题