39. Quartz Scheduler

Spring Boot offers several conveniences for working with the Quartz scheduler, including the spring-boot-starter-quartz ‘Starter’. If Quartz is available, a Scheduler will be auto-configured (via the SchedulerFactoryBean abstraction).

Beans of the following types will be automatically picked up and associated with the the Scheduler:

By default, an in-memory JobStore will be used. However, it is possible to configure a JDBC-based store if a DataSource bean is available in your application and if the spring.quartz.job-store-type property is configured accordingly:


When the jdbc store is used, the schema can be initialized on startup:


The database is detected by default and initialized using the standard scripts provided with the Quartz library. It is also possible to provide a custom script using the spring.quartz.jdbc.schema property.

Quartz Scheduler configuration can be customized using Quartz configuration properties (see spring.quartz.properties.*) and SchedulerFactoryBeanCustomizer beans which allow programmatic SchedulerFactoryBean customization.

Job can define setters to inject data map properties. Regular beans can also be injected in a similar manner:

public class SampleJob extends QuartzJobBean {

    private MyService myService;
    private String name;

    // Inject "MyService" bean
    public void setMyService(MyService myService) { ... }

    // Inject the "name" job data property
    public void setName(String name) { ... }

    protected void executeInternal(JobExecutionContext context)
            throws JobExecutionException {