erdem
erdem

Reputation: 113

How should be project structure using microservices with gradle or maven?

I want to be sure what is the best practice for project structure while using microservice architecture.

All microservices can be created as a new maven/gradle project or as a subproject/module.

I think dependency inheritance, project repository should be taken into account.

Due to the nature of the microservices, any service can has a different technology but still most of the services can have same dependencies(e.g. spring-boot)).

Another issue is that should team fetch all services or just a service which will be worked on? so repository structure also will be affected by the structure.

Upvotes: 3

Views: 4548

Answers (2)

Javier C.
Javier C.

Reputation: 8267

I don't recommend you to have a single project with multiple microservices of different technologies.

If you use Java as a programming language you can have a master project and use it as a parent in your microservices projects. Also, you can have common libraries as dependencies of your microservices projects.

If you want to do a microservices with different technology I recommend you to have a repository for each microservice.

Choosing this option you can deploy and versioning each microservice when you do changes in its code and not when you have changes in another microservice.

Upvotes: 3

J Fabian Meier
J Fabian Meier

Reputation: 35903

The main reasons to have a multi-module project is to manage dependencies (in the maven sense) between the different modules (and build them together in the right order). Your microservices may call each other, but are not dependent on each other in the Maven sense. So I would not use multi-module projects for them.

Nevertheless, you can define a parent pom for your microservices that defines common configuration and dependencies.

Upvotes: 3

Related Questions