spring-boot
Shutdown a Spring Boot Application
張's blog
2023. 7. 19. 18:25
- ServletContextListener 구현 후 Bean 등록하면 종료 이벤트 메소드에서 작업 가능
- graceful shutdown custom
https://www.springcloud.io/post/2022-02/spring-boot-graceful-shutdown/#gsc.tab=0
- shutdown spring boot Application
https://www.baeldung.com/spring-boot-shutdown
- errorChannel 에러 발생시 참고
https://solace.community/discussion/272/immediate-application-shutdown-after-succesful-start
@SpringBootApplication
public class Application {
private static final Logger logger = LoggerFactory.getLogger(Application.class);
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
@Bean
public Consumer<String> appCreatedConsumer() {
return String -> {
System.out.println("String created: " + String);
};
}
@Bean
public Supplier<String> appCreatedSupplier() {
return () -> new String("Test");
}
}