1

I am setting up a few CronTriggers to kickoff a few different batch jobs at different times.

I have tried to search online, but can only find answers on how to schedule after say a web call or inside a different service class. I want theses triggers to be scheduled on startup.

How can I do that?

I have already built the Triggers and the JobDetails via their respective builders.

I am using Spring-boot-starter-quartz

needoriginalname
  • 703
  • 3
  • 9
  • 27

1 Answers1

0

I believe what you are looking for is to create a class that implements ApplicationRunner or CommandLineRunner. On startup of a spring application, spring will execute run command in this class and you can programmatically call your task on startup.

See this if you want more info:

https://www.concretepage.com/spring-boot/spring-boot-commandlinerunner-and-applicationrunner-example

Edwin M. Cruz
  • 362
  • 1
  • 8
  • Thanks, I already tried this. I just now double checked my code, my problem wasn't the wiring. It was the fact that I was returning null on my triggers because they weren't built. – needoriginalname Mar 12 '19 at 22:09
  • Turns out I did not call the function afterPropertiesSet(). And, turns out that I didn't need to use CommandLineRunner at all because Spring-boot-starter-quartz seems to schedule them automatically. ... RIP ME – needoriginalname Mar 12 '19 at 22:14