In Quartz, a JobDetail describes what to run: it holds the job class, an identity (name and group) and a JobDataMap of parameters. A Trigger describes when to run it: a start time, an interval or a cron expression, and optional end conditions. The two are separate objects, so one JobDetail can have many triggers, and the scheduler combines them at runtime to fire the job.
Spring Boot's Quartz starter registers every JobDetail and Trigger bean with the scheduler automatically. This article shows the roles of both classes, how to configure them in Spring Boot 3, the common trigger types and how misfire handling and persistence behave.
JobDetail is the definition of a unit of work. It contains:
org.quartz.Job and holds the logic.JobKey made of a name and a group, which must be unique in the scheduler.JobDataMap with parameters passed to each execution.JobDetail has no schedule. A durable job (storeDurably()) stays in the job store even when no trigger points to it. A non-durable job is removed automatically once its last trigger is gone. Quartz creates a new job instance for every execution, so keep job classes stateless and put data in the JobDataMap or in your own services.
A Trigger holds scheduling rules and points to a job through a JobKey. Its main properties are:
TriggerKey (name and group).JobDataMap, which is merged with the job's map at execution time and overrides keys with the same name.When the trigger fires, the scheduler creates the job from the JobDetail and runs execute() on a worker thread.
Add spring-boot-starter-quartz, then define the job, the JobDetail and the Trigger:
Spring Boot creates job instances through Spring's job factory, so @Autowired fields work in the job class without registering the job as a @Component. The JobDataMap values travel with the job and are read through getMergedJobDataMap(), which combines the job and trigger data.
| Trigger | Use it for | Builder |
|---|---|---|
SimpleTrigger | Fixed interval and repeat count | SimpleScheduleBuilder |
CronTrigger | Calendar based schedules | CronScheduleBuilder |
CalendarIntervalTrigger | Every N days, weeks or months | CalendarIntervalScheduleBuilder |
DailyTimeIntervalTrigger | Every N minutes within a daily window | DailyTimeIntervalScheduleBuilder |
A cron trigger runs at 08:30 on weekdays like this:
Quartz cron expressions have six or seven fields (seconds first), unlike the five-field Unix format. Always set a time zone, because the default is the JVM zone and it changes behaviour around daylight saving time.
By default Spring Boot uses an in-memory job store, so schedules vanish on restart and each application instance runs every job. To persist and to run in a cluster, switch to the JDBC store:
With a JDBC store, job and trigger rows live in the QRTZ_* tables, and in clustered mode only one node fires each trigger. Use initialize-schema=never in production and manage the schema with a migration tool.
A misfire happens when a trigger could not fire on time, for example because the application was down or all worker threads were busy. The misfire instruction chooses between firing immediately, skipping the missed runs or rescheduling. Pick it deliberately for jobs where duplicates or gaps matter.
| Aspect | JobDetail | Trigger |
|---|---|---|
| Answers | What to run | When to run |
| Identity | JobKey | TriggerKey |
| Parameters | JobDataMap | Own JobDataMap, merged at runtime |
| Relationship | Can have many triggers | Belongs to exactly one job |
| Typical builder | JobBuilder | TriggerBuilder |
Yes. Several triggers can point to the same JobDetail, each with its own schedule and data, such as one cron trigger for nightly runs and one simple trigger for a manual retry.
It keeps the JobDetail in the job store even when it has no triggers. Without it, Quartz deletes the job when the last trigger completes.
Use @Scheduled for simple in-process timers. Choose Quartz when you need persistence, clustering, dynamic scheduling, misfire policies or job data.
No. Spring Boot's scheduler factory creates job instances and autowires them, so a plain class implementing Job works.
JobDetail says what runs and Trigger says when it runs. Define both as beans in Spring Boot 3 with spring-boot-starter-quartz, give them stable names and groups, use cron triggers with an explicit time zone, and switch to the JDBC job store for persistence and clustering. Attach several triggers to one job when the same work needs different schedules.