问题
I am new for scheduler in spring. I read so many articles on @schedule but in every example they gave time in seconds and milliseconds.
Problem Statement : As per my requirement, after my program start my scheduler will start after 15 minutes (initial Delay ) and then it executes the task every after 5 minutes (FixedRate) . To achieve this how can I give time in minutes is their any best way to achieve this problem ?
Code :
@Configuration
@EnableScheduling
public class ScheduledConfiguration {
@Scheduled(fixedDelay = 300000, initialDelay = 900000)
public void scheduleFixedRateWithInitialDelayTask() {
long now = System.currentTimeMillis() / 1000;
System.out.println("Fixed rate task with one second initial delay - " + now);
}
}
By using above program i will achive but I want to avoid 300000 / 900000 milliseconds . Other way
@Scheduled(fixedDelay = 5 * 60 * 1000, initialDelay = 15 * 60 * 1000)
来源:https://stackoverflow.com/questions/61749805/how-to-give-minute-in-fixeddelay-initialdelay-in-scheduled-spring-boot