8

I need to be able to set up quartz to run depending on the profile. I am using an integration test to make sure that each profile is getting the scheduler started (or not), but I am checking a profile that doesn't have it enabled and this check is failing:

assertFalse(scheduler.isStarted());

This is what I have used for this profile in application.yaml:

spring:
  quartz:
    enabled: false

Also tried:

spring:
  quartz:
    properties:
      enabled: false

Any ideas how to get quartz to not start at all?

As a workaround, is it possible to set up a dummy scheduler on the profile so that the real quartz is skipped altogether?

PS I have noticed this, but I'd like to keep it in application.yaml if at all possible: How to disable Quartz scheduler for dev and stg environment

eftshift0
  • 26,375
  • 3
  • 36
  • 60

2 Answers2

10

this worked:

spring:
  quartz:
    auto-startup: false
eftshift0
  • 26,375
  • 3
  • 36
  • 60
2

In my case, disabling spring.quartz.auto-startup wasn't enough. Quartz was still happily starting and reporting so in the logs:

org.quartz.impl.StdSchedulerFactory      : Using default implementation for ThreadExecutor
org.quartz.core.SchedulerSignalerImpl    : Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
org.quartz.core.QuartzScheduler          : Quartz Scheduler v.2.3.2 created.
(...)
org.quartz.core.QuartzScheduler          : JobFactory set to: org.springframework.scheduling.quartz.SpringBeanJobFactory@4560eb15

I had to add:

@EnableAutoConfiguration(exclude = { QuartzAutoConfiguration.class })

to the

@SpringBootApplication(...)

...to get rid of it.

Update: Version is Spring Boot v2.7.7, Spring v5.3.24.

zb226
  • 9,586
  • 6
  • 49
  • 79