In my case, I am using spring boot and MySQL DB. I am having two database users.
- Admin user is used by liquibase to create tables. It is having its own data source.
- Dev User is used to read/write data to the tables. It is having another data source.
@Bean
public DataSource devDataSource() {
HikariDataSource dataSource = new HikariDataSource();
...
...
return dataSource;
}
@Bean
public DataSource liquibaseDataSource() {
HikariDataSource dataSource = new HikariDataSource();
...
...
return dataSource;
}
Now I am trying to add the Spring batch to the service. I am getting a duplicate bean exception. It is getting fixed when I am adding @Primary to liquibase datasource, but we dont want to use this for read/write operations for batch.
If I add @Primary in the Dev User data source the batch meta-data tables are not getting created. As far as I understood, Dev User is not having the privilege to create the table. So when Dev data source is configured for batch, the tables are not getting created.
I want to create batch meta-data table via spring config(automatically) and for all read, and write to all tables(including batch meta table) via Dev user if possible.
Not sure what I am missing here. any help is appreciated