Adding Persistence
In this chapter, we will learn how to persist data that a microservice is using. As already mentioned in Chapter 2, Introduction to Spring Boot, we will use the Spring Data project to persist data to MongoDB and MySQL databases.
The product
and recommendation
microservices will use Spring Data for MongoDB and the review
microservice will use Spring Data for the JPA (short for the Java Persistence API) to access a MySQL database. We will add operations to the RESTful APIs to be able to create and delete data in the databases. The existing APIs for reading data will be updated to access the databases. We will run the databases as Docker containers, managed by Docker Compose, that is, in the same way as we run our microservices.
The following topics will be covered in this chapter:
- Adding a persistence layer to the core microservices
- Writing automated tests that focus on persistence
- Using the persistence layer in the service layer ...