【发布时间】:2023-04-10 23:15:01
【问题描述】:
我们可以在 Spring Boot 应用程序中使用 @Scheduled 轻松安排作业。
有没有办法使用任何休息端点知道当前正在运行的计划作业?
【问题讨论】:
标签: spring-boot spring-scheduled
我们可以在 Spring Boot 应用程序中使用 @Scheduled 轻松安排作业。
有没有办法使用任何休息端点知道当前正在运行的计划作业?
【问题讨论】:
标签: spring-boot spring-scheduled
是的,您需要将 Spring 引导执行器作为您的依赖项之一。然后您可以使用 scheduletasks 端点来检查计划任务:
https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html
只需将以下内容添加到您的 pom.xml 中
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
端点位于 /actuator/scheduledtasks
【讨论】: