I have a current requirement of allowing multiple data sources for the same repositories/entities in spring boot using jpa.
What I've managed to find was always related to multiple datasources, with multiple repositories/entites.
However, here I would like to have the same repositories and entities (ie same database structure) for multiple datasources.
And based on same property, programmatically activate a specific datasource.
I've tried the setup demo'ed here: https://github.com/spring-projects/spring-data-examples/tree/master/jpa/multiple-datasources
And in both configurations use the same package in the factoryBean.setPackagesToScan() call. This does now work however, one datasource overrides the other.
My current test can be found here: https://github.com/nWidart/spring-data-multi-datasource/tree/master/src/main/java/com/example/multidatasources
It shows the 2 configuration files (client1 and client2) with a repository and entity. The controller has 2 endpoints for both data sources (not working).
Thanks!


