java - Initialize Spring batch DB before application bean is created -
i'm trying create bean so:
@bean public clock clock(jobexplorer explorer, environment environment) { // check last run time of job , create clock bean } but when application starts up, error: ora-00942: table or view not exist because spring batch schema hasn't been created spring boot's batchautoconfiguration yet.
then, tried this:
@bean @conditiononbean(batchdatabaseinitializer.class) public clock clock(jobexplorer explorer, environment environment) { // check last run time of job , create clock bean } this shifted error when clock bean created when bean requiring clock created:
@bean(name = "reader") public itemreader<record> itemreader( jdbctemplate jdbctemplate, clock clock) { // create item reader } error: no qualifying bean of type [java.time.clock] found dependency
this keeps cascading. if put @conditionalonbean on itemreader method, when bean requires itemreader created, same "no qualifying bean" error.
so, how make sure spring batch schema initialized before beans created?
have tried use @dependson() annotation? not aware of conditiononbean..
Comments
Post a Comment