How to distribute the entities among projects?

Asked

Viewed 208 times

1

I have doubts whether there are good practices for the distribution of entities between projects. Let’s say I have a java REST microservice that provides a client (id, name, address) through GET and another microservice that needs to consume this first microservice.

How could I avoid duplicating code between these two projects? Putting the client entity in a separate JAR and making the two microservices use this JAR as dependency? Have another way to minimize code duplication between these microservices in java?

1 answer

2


Surely this can be a big issue when it comes to distributed systems like Microservices, you can distribute the classes in common in one JAR separate and use in projects, but for this to really work the coverage of Tests and the correct versioning of dependencies is fundamental, because imagine a possible change in this lib, this could impact directly on your projects.

But another important point, this strategy of libs works when you have few MS in architecture, when the amount increases it gets very complicated to control these dependencies, then the output is creating the specific codes for each MS.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.