I have a Spring Boot (2.1.3) project using the Quartz scheduler. It is included via the starter:
dependencies {
...
implementation('org.springframework.boot:spring-boot-starter-quartz')
}
The application is (mainly) configured with component scanning. If I run the application everything is fine. If I run a test annotated with @SprinBootTest
everything is fine, too. But if I use this custom annotation
@DataJpaTest
@ComponentScan(basePackages = ["com.mycompany"])
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@ActiveProfiles("intTest")
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
@Inherited
annotation class JpaTest
instead of @SpringBootTest
I get a NoSuchBeanDefinitionException
because no Quartz Scheduler
could be found.
I've tried to add the Quartz package to the component scan, but that doesn't help:
@ComponentScan(basePackages = ["com.mycompany", "org.quartz"])
How can make Spring to pick up the Scheduler with my test setup with my custom configuration annotation?