I am writing a Spring Batch job and don't care about restarts and don't want the hassle of creating, securing and managing an Oracle schema for Spring Batch database objects. H2 on the file system is more than enough for us.
The issue is that I am writing an batch job that needs to connect to an Oracle database and failing miserably just trying to get 2 data sources, transaction managers and entity managers. Right now I am trying two H2 database and haven't even tried configuring Oracle database yet.
I have used two Oracle data sources in other Spring Boot applications successfully in the past but this is my first attempt with Spring Batch that has configuration code to create the data source.
I have tried creating two DataSource
, EntityManagerFactoryBean
and TransactionManager
with one using default spring.datasources
configuration, default bean names and @Primary
.
I have tried creating just a second DataSource
, EntityManagerFactoryBean
and TransactionManager
with different bean names. This seems to have an issue that the TransactionManager or
EntityManager is already assigned to the thread.
I have tried creating a dataSource
for batch but run into circular bean creation errors.
I have tried creating a BatchConfigurer
and that runs into circular bean creation errors.
I have tried creating a JobRepositoryFactoryBean
but a default one is still created.
I have tried using a @PersistenceContext
on my @Entity
classes.
It shouldn't be this hard so I must be missing something. Any help would be appreciated.
Thanks, Wes.