1

I need a scheduled job in my spring application with fixed day-time (10AM in this example):

@Scheduled(cron="0 0 10 * * *")
public void mytask(){
...
}

The problem is that I want to let user configure the start time, I have the time string in my database, how can I change or setup a new cron job at runtime in spring? I think I cannot use annotations.

Tobia
  • 9,165
  • 28
  • 114
  • 219
  • Here is an answer fix your requirement - https://stackoverflow.com/questions/14630539/scheduling-a-job-with-spring-programmatically-with-fixedrate-set-dynamically/14632758#14632758 – Liping Huang Sep 01 '17 at 06:39
  • Can I setup it from a @Service? – Tobia Sep 01 '17 at 06:43

0 Answers0