springboot定时任务立即执行
时间: 2023-10-19 07:35:49 浏览: 78
要使Spring Boot定时任务立即执行,可以使用@Scheduled注解中的initialDelay属性来实现。initialDelay属性指定了任务启动后的延迟时间,可以将其设置为0,表示立即执行任务。在启动类上添加@EnableScheduling注解开启定时任务功能后,只需在定时任务的方法上添加@Scheduled(initialDelay = 0)注解即可。这样定时任务将在应用启动后立即执行。 <span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [SpringBoot定时执行任务](https://blog.csdn.net/weixin_59067508/article/details/126473541)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [springboot定时器,定时执行任务](https://blog.csdn.net/qq_33697094/article/details/110957355)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文