我有一个使用 Quartz 调度程序的 Spring Boot (2.1.3) 项目。它通过启动器包含在内:
dependencies {
...
implementation('org.springframework.boot:spring-boot-starter-quartz')
}
该应用程序(主要)配置有组件扫描。如果我运行应用程序一切都很好。如果我运行一个带有@SprinBootTest
所有注释的测试也很好。但是如果我使用这个自定义注释
@DataJpaTest
@ComponentScan(basePackages = ["com.mycompany"])
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@ActiveProfiles("intTest")
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
@Inherited
annotation class JpaTest
而不是@SpringBootTest
我得到一个NoSuchBeanDefinitionException
,因为找不到石英Scheduler
。
我尝试将 Quartz 包添加到组件扫描中,但这无济于事:
@ComponentScan(basePackages = ["com.mycompany", "org.quartz"])
如何使用我的自定义配置注释让 Spring 使用我的测试设置来选择调度程序?