Building microservices from a monolith
One common question that I have already heard dozens of times is, "how do I break down my monolith into microservices?", or, "how do I migrate from a monolith approach to microservices?"
Well, that's what this recipe is all about.
Getting ready
For both monolith and microservice projects, we will use the same dependency:
<dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>8.0</version> <scope>provided</scope> </dependency>
How to do it...
Let's begin by building a monolith to split into microservices.
Building a monolith
First, we need the entities that will represent the data kept by the application.
Here is the User
entity:
@Entity public class User implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long...