Starter for using the Quartz scheduler in Spring Boot applications with auto-configuration support
—
Type-safe configuration properties for customizing Quartz behavior through application.properties or application.yml. Provides comprehensive control over scheduler settings, job store configuration, and database initialization.
Main configuration properties class bound to the spring.quartz prefix, providing type-safe access to all Quartz-related settings.
/**
* Configuration properties for Quartz Scheduler integration
* Bound to spring.quartz configuration prefix
*/
@ConfigurationProperties("spring.quartz")
public class QuartzProperties {
/**
* Get the job store type (MEMORY or JDBC)
* @return JobStoreType enum value (default: MEMORY)
*/
public JobStoreType getJobStoreType();
/**
* Set the job store type
* @param jobStoreType MEMORY for in-memory storage, JDBC for database storage
*/
public void setJobStoreType(JobStoreType jobStoreType);
/**
* Get the scheduler name
* @return Scheduler name or null if not set
*/
public String getSchedulerName();
/**
* Set the scheduler name
* @param schedulerName Name for the scheduler instance
*/
public void setSchedulerName(String schedulerName);
/**
* Check if scheduler should start automatically after initialization
* @return true if auto-startup is enabled (default: true)
*/
public boolean isAutoStartup();
/**
* Set auto-startup behavior
* @param autoStartup true to start scheduler automatically
*/
public void setAutoStartup(boolean autoStartup);
/**
* Get startup delay duration
* @return Duration to wait before starting scheduler (default: 0 seconds)
*/
public Duration getStartupDelay();
/**
* Set startup delay
* @param startupDelay Time to wait before starting scheduler after initialization
*/
public void setStartupDelay(Duration startupDelay);
/**
* Check if scheduler should wait for jobs to complete on shutdown
* @return true if should wait for job completion (default: false)
*/
public boolean isWaitForJobsToCompleteOnShutdown();
/**
* Set shutdown behavior for running jobs
* @param waitForJobsToCompleteOnShutdown true to wait for jobs to complete
*/
public void setWaitForJobsToCompleteOnShutdown(boolean waitForJobsToCompleteOnShutdown);
/**
* Check if configured jobs should overwrite existing job definitions
* @return true if jobs should be overwritten (default: false)
*/
public boolean isOverwriteExistingJobs();
/**
* Set job overwrite behavior
* @param overwriteExistingJobs true to overwrite existing jobs with same identity
*/
public void setOverwriteExistingJobs(boolean overwriteExistingJobs);
/**
* Get additional Quartz Scheduler properties
* @return Map of property keys to values
*/
public Map<String, String> getProperties();
/**
* Get JDBC-specific configuration
* @return Jdbc configuration object
*/
public Jdbc getJdbc();
}Usage Examples:
# Basic scheduler configuration
spring.quartz.scheduler-name=MyAppScheduler
spring.quartz.auto-startup=true
spring.quartz.startup-delay=10s
spring.quartz.wait-for-jobs-to-complete-on-shutdown=true
spring.quartz.overwrite-existing-jobs=false
# Job store selection
spring.quartz.job-store-type=memory
# or
spring.quartz.job-store-type=jdbc
# Advanced Quartz properties
spring.quartz.properties.org.quartz.scheduler.instanceId=AUTO
spring.quartz.properties.org.quartz.scheduler.makeSchedulerThreadDaemon=true
spring.quartz.properties.org.quartz.jobStore.useProperties=true
spring.quartz.properties.org.quartz.threadPool.threadCount=5# YAML configuration
spring:
quartz:
scheduler-name: MyAppScheduler
auto-startup: true
startup-delay: 10s
wait-for-jobs-to-complete-on-shutdown: true
job-store-type: jdbc
properties:
org.quartz.scheduler.instanceId: AUTO
org.quartz.jobStore.driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.tablePrefix: QRTZ_
org.quartz.jobStore.isClustered: true
org.quartz.jobStore.clusterCheckinInterval: 20000Enumeration defining the supported Quartz job store types.
/**
* Enumeration for supported Quartz job store types
*/
public enum JobStoreType {
/**
* Store jobs in memory (default)
* Jobs and triggers are lost on application restart
* Suitable for development and simple scheduling needs
*/
MEMORY,
/**
* Store jobs in database
* Jobs and triggers persist across application restarts
* Supports clustering and high availability
* Requires DataSource configuration
*/
JDBC
}Nested configuration class for JDBC job store specific settings.
/**
* JDBC-specific configuration properties for Quartz
* Nested class within QuartzProperties
*/
public static class Jdbc {
/**
* Get the path to SQL schema initialization script
* @return Schema script location (default: classpath:org/quartz/impl/jdbcjobstore/tables_@@platform@@.sql)
*/
public String getSchema();
/**
* Set schema script location
* @param schema Path to SQL script for schema initialization
*/
public void setSchema(String schema);
/**
* Get database platform for schema script selection
* @return Platform name (auto-detected by default)
*/
public String getPlatform();
/**
* Set database platform
* @param platform Platform name to use in @@platform@@ placeholders
*/
public void setPlatform(String platform);
/**
* Get database schema initialization mode
* @return DatabaseInitializationMode enum value (default: EMBEDDED)
*/
public DatabaseInitializationMode getInitializeSchema();
/**
* Set schema initialization mode
* @param initializeSchema ALWAYS, EMBEDDED, or NEVER
*/
public void setInitializeSchema(DatabaseInitializationMode initializeSchema);
/**
* Get prefixes for single-line comments in SQL scripts
* @return List of comment prefixes (default: ["#", "--"])
*/
public List<String> getCommentPrefix();
/**
* Set comment prefixes for SQL script parsing
* @param commentPrefix List of strings that start SQL comments
*/
public void setCommentPrefix(List<String> commentPrefix);
}JDBC Configuration Examples:
# JDBC job store configuration
spring.quartz.job-store-type=jdbc
spring.quartz.jdbc.initialize-schema=embedded
spring.quartz.jdbc.platform=postgresql
spring.quartz.jdbc.schema=classpath:custom-quartz-schema.sql
spring.quartz.jdbc.comment-prefix=#,--,//
# Database-specific job store properties
spring.quartz.properties.org.quartz.jobStore.class=org.springframework.scheduling.quartz.LocalDataSourceJobStore
spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
spring.quartz.properties.org.quartz.jobStore.tablePrefix=QRTZ_
spring.quartz.properties.org.quartz.jobStore.misfireThreshold=60000# Enable clustering for high availability
spring.quartz.properties.org.quartz.jobStore.isClustered=true
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval=20000
spring.quartz.properties.org.quartz.scheduler.instanceId=AUTO
spring.quartz.properties.org.quartz.scheduler.instanceName=MyClusteredScheduler# Configure thread pool for job execution
spring.quartz.properties.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
spring.quartz.properties.org.quartz.threadPool.threadCount=10
spring.quartz.properties.org.quartz.threadPool.threadPriority=5
spring.quartz.properties.org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread=true# Job persistence and recovery settings
spring.quartz.properties.org.quartz.jobStore.useProperties=true
spring.quartz.properties.org.quartz.plugin.jobInitializer.class=org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
spring.quartz.properties.org.quartz.plugin.jobInitializer.fileNames=jobs.xml
spring.quartz.properties.org.quartz.plugin.jobInitializer.failOnFileNotFound=trueSpring Boot validates configuration properties at startup:
# Development environment
spring.profiles.active=dev
spring.quartz.job-store-type=memory
spring.quartz.auto-startup=true
spring.quartz.properties.org.quartz.scheduler.makeSchedulerThreadDaemon=true
# Production environment
spring.profiles.active=prod
spring.quartz.job-store-type=jdbc
spring.quartz.properties.org.quartz.jobStore.isClustered=true
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval=20000
spring.quartz.startup-delay=30sInstall with Tessl CLI
npx tessl i tessl/maven-org-springframework-boot--spring-boot-starter-quartz