Spring - Scheduled Task - Graceful Shutdown
问题 I have a Spring-Boot application with a bean running a scheduled task at about 1 minute intervals, and this bean has a @PreDestroy method. Is there a solution for allowing a task which is currently being executed to complete - or at least given some time to complete - before the life cycle reaches the pre-destroy phase? 回答1: You need update configuration of ThreadPoolTaskScheduler . Set true for waitForJobsToCompleteOnShutdown (method setWaitForTasksToCompleteOnShutdown ). From documentation: