Creating Multi-Modules Maven Project in Eclipse

In this tutorial I will explain you how to create multi-modules maven project in Eclipse. This kind of project is a good design when you want to group similar projects. The packaging type in parent pom file should pom.

Please follow below steps to create the multi-modules maven project.

  1. Create New maven project in Eclipse menu. Select Archetype as maven-archetype-quickstart. In next window input Group Id, Artifact Id etc. For example, Group Id – jeejava, Artifact Id – spring-microservices, Version – by default auto populated. Now open the pom.xml file and change the packaging type as pom. If you find any problem on the project then simply do Maven -> Update Project.
  2. Now do right click on the spring-microservices project and click New -> Other. In the Wizard window select Maven -> Maven Module. In the next window input Module Name as user-service. Make sure that Parent Project selected as spring-microservices. On next window select Archetype as maven-archetype-quickstart. In next window accept all defaults and click Finish. Now you will see in the parent project’s (spring-microservices) pom has been updated with <modules/> tag. Now open the user-service project’s pom.xml file and remove <groupid/> and <version/> tags. Because these two values will be inherited from parent project.
  3. Now create another module email-service in the similar way as you have created user-service. Remove the <groupid/> and <version/> tags from the pom.xml file. Now again you will see the parent’s pom file has been updated to include the email-service module under <modules/> tag.

The project structure will look like similar to the below image

multi module maven project

Now you can add dependencies, plugins etc in individual children pom files as per the project requirements. You can also add common dependencies, plugins etc. in the parent project’s pom file and those dependencies will be automatically inherited in the child’s pom file. If you want to override any inherited dependency in child pom then you need to declare the same dependency in child’s pom file.

Thanks for reading.

Soumitra Roy Sarkar

I am a professional Web developer, Enterprise Application developer, Software Engineer and Blogger. Connect me on Roy Tutorials Twitter Facebook  Google Plus Linkedin

One Reply to “Creating Multi-Modules Maven Project in Eclipse”

Leave a Reply

Your email address will not be published. Required fields are marked *