Let's start with adding a persistence layer to the core microservices. Besides using Spring Data, we will also use a Java bean mapping tool, MapStruct, that makes it easy to transform between Spring Data entity objects and the API model classes. For further details, see http://mapstruct.org/.
First, we need to add dependencies to MapStruct, Spring Data, and the JDBC drivers for the databases we intend to use. After that, we can define our Spring Data entity classes and repositories. The Spring Data entity classes and repositories will be placed in their own Java package, persistence. For example, for the product microservice, they will be placed in the Java package, se.magnus.microservices.core.product.persistence.