【发布时间】:2015-06-05 22:40:09
【问题描述】:
我正在尝试像这样创建一个 bean:
@Bean
public Clock clock(JobExplorer explorer, Environment environment) {
// Check last run time of job and create a Clock bean
}
但是当应用程序启动时,我收到错误:ORA-00942: table or view does not exist,因为 spring 批处理模式尚未由 spring boot 的 BatchAutoConfiguration 创建。
然后,我尝试这样做:
@Bean
@ConditionOnBean(BatchDatabaseInitializer.class)
public Clock clock(JobExplorer explorer, Environment environment) {
// Check last run time of job and create a Clock bean
}
这将错误从创建时钟 bean 时转移到创建需要 Clock 的 bean 时:
@Bean(name = "reader")
public ItemReader<Record> itemReader(
JdbcTemplate jdbcTemplate, Clock clock) {
// Create item reader
}
Error: No qualifying bean of type [java.time.Clock] found for dependency
这一直在级联。如果我将@ConditionalOnBean 放在itemReader 方法上,那么当创建需要itemReader 的bean 时,我会得到同样的“没有合格的bean”错误。
那么,如何确保在创建 bean 之前初始化 spring 批处理模式?
【问题讨论】:
标签: java spring spring-boot spring-batch