I want to load multitenant database from a database not from properties file. I am following this tutorial (https://fizzylogic.nl/2016/01/24/make-your-spring-boot-application-multi-tenant-aware-in-2-steps/). This is how my DataSource Bean looks like:
@Bean
public DataSource dataSource() {
Map<Object, Object> resolvedDataSources = this.multiTenantDbBuilder.getResolvedDataSources();
TenantAwareRoutingSource dataSource = new TenantAwareRoutingSource();
dataSource.setDefaultTargetDataSource(this.defaultDataSource());
dataSource.setTargetDataSources(resolvedDataSources);
dataSource.afterPropertiesSet(); // Call this to finalize the initialization of the data source.
return dataSource;
}
I would like to retrieve my resolvedDataSources from a database (the default one), the problem is that i am not able to use JPA because DataSource bean has not been created already.
Thank you all !