在Spring Boot应用程序中安排任务的最佳方法是什么


问题内容

我目前正在开发基于Spring-Boot的应用程序。

我知道像@Scheduled这样的注释可以安排任务。由于我应用程序中的用户希望在不同的时间发送邮件,并且只发送一次。

我已经阅读了Spring调度后的文章-仅运行一次,但是在基于Spring的应用程序中总是“新”一个localExecutor很奇怪。

这样,一旦用户计划发送电子邮件,我就必须为他的任务“新建”一个localExecutor。

那么,还有什么更好的方法吗?


问题答案:

你应该使用quartz-schedulersend mails at different time and send only once.-把这个作为代码中的业务逻辑。请参阅有关spring boot -quartz集成的
https://github.com/davidkiss/spring-boot-quartz-
demo