- How to configure multiple data sources in Spring data JPA?
- Can we configure Spring Boot to use multiple data sources?
How to configure multiple data sources in Spring data JPA?
To configure multiple data sources in Spring Data JPA we need to group the Model classes and Repository interfaces for each data source under different packages, this is how we tell Spring what belongs to which data source. Assuming that package names given in below example and comments itself are self explanatory.
Can we configure Spring Boot to use multiple data sources?
To make a spring boot application that can communicate with more than one database you need to define some configuration to let spring boot when to execute each source. let's agree first that your /models and /repositories and /controllers are already defined as you always do.