what is the correct way of scheduling one-shot task (runnable) programmatically given time from now in springboot? I cannot find that information anywhere. IIUC I'd like to call
org.springframework.scheduling.TaskScheduler#scheduleWithFixedDelay(java.lang.Runnable, java.util.Date, long)
but TaskScheduler
cannot be injected (autoconfigured). Same for ScheduledTaskRegistrar
. I can start my own quartz, but that's not right. I want to do it correctly and reuse what's already implemented in springboot. Again, I need to do it programmatically, ie. invoke this, one minute from now, thus no annotations. Even if I implement SchedulingConfigurer
, ScheduledTaskRegistrar
passed into configureTask does not have set TaskScheduler
.
This seems to be completely undocumented, while this should be really easy to do. Can someone advice?
EDIT: sorry I missread the documentation, desired method is org.springframework.scheduling.TaskScheduler#schedule(java.lang.Runnable, java.util.Date)
, as one mentioned above invokes the job multiple times, while just once is desired. But the crux is getting in touch with TaskScheduler in firstplace, so the rest holds. Note: manually configuring ThreadPoolTaskScheduler
works, but shouldn't there be one already configured by springboot if @EnableScheduling
is present?