#69 - Added example for how to set up Spring Data JPA with two DataSources.

This commit is contained in:
Oliver Gierke
2015-03-19 10:04:46 +01:00
parent 65cef4132d
commit 9ecb720f4a
13 changed files with 640 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
# Spring Data JPA - Multiple datasources example
This project contains an example of how to set up Spring Data to work with two independent databases. Note, that this example is not about JTA transactions spanning multiple databases but rather just interacting with separate databases through a cleanly separated domain model and Spring Data repositories.
## Interesting points to look at
Two connect to two databases we need to manually configure a `DataSource`, `EntityManagerFactory` and `JpaTransactionManager`. This is done in `CustomerConfig` and `OrderConfig`. `DataInitializer` then simulates a Spring component interacting with those databases in separate methods. `Application.init()` orchestrates calls to those methods.