Refactoring the database
A key concept of microservices is that they are independent of each other. This means that they should have separate databases. However, we would not want each microservice to have a copy of the tables used for authentication as this would lead to an unhealthy quantity of duplicated data. It would also lead to the risk of the authentication data getting out of sync. For this reason, we need a way of using two separate databases in a single microservice. These are the database for the service and the database for authentication.
Fortunately, there is a way to accomplish this using Spring Boot by making changes only to our configuration code and not our implementation code.
Our configuration for persistence was as follows:
@Configuration @EnableJpaRepositories( basePackages = {"uk.me.jasonmarston.domain.repository"}) @EnableTransactionManagement public class PersistenceConfig { }
The preceding configuration class simply enabled Spring Boot...