Spring JPA project that support read/write split.
Abstract class AbstractRoutingDataSource give us the capability to manage multiple datasources in the same spring project. It will do the dynamic routing for the application to use different datasource at runtime.
Multiple datasources are actully the idea behind our read/write split implementation. What we actually need to do is to enable the switch of read/write datasource at runtime.
We use the HikariCP connection pool.
We use the annotation at the method level to decide the read(slave) or write(master) datasource. We use AOP to enabled he annotation.
We use Redis as the cache layer.
To create the Docker image and container, run the following maven command and docker command:
$ mvn clean install docker:removeImage docker:build -Denv=dev -Dmaven.test.skip=true
$ docker run -d --name spring-jpa --link mysql-master:mysql-master --link mysql-slave:mysql-slave --link redis-master:redis-master -p 8080:8080 jin/spring-jpa