Multi-tenancy: Managing multiple datasources with Spring Data JPA
To implement multi-tenancy with Spring Boot we can use AbstractRoutingDataSource as base DataSource class for all ‘tenant databases‘. It has one abstract method determineCurrentLookupKey that we have to override. It tells the AbstractRoutingDataSource which of the tenant datasource it has to provide at the moment to work with. Because it works in the multi-threading environment, … Read more