Create multiple module project maven eclipse

Create multiple module project maven eclipse

This demo will show you how to create multiple module project maven eclipse and in order to create multiple module project please use eclipse with maven plug-in. We will use eclipse Kepler to create project and this comes with maven plug-in installed. Please follow below steps:

  • In eclipse click File –> New –> Other –> Maven –> Maven Project then click Next:

Create multiple module project maven eclipse

  • Next screen select as below and click Next:

Create multiple module project maven eclipse

  • Next select as below then click Finish:

Create multiple module project maven eclipse

  • You will see Parent module got created with name JavaHonkParentModule as below:

Create multiple module project maven eclipse

  • Now lets add module in it. We will add two module here for demo and where our childModule1 will be dependent on ChildModule1. To create –> Right click JavaHonkParentModule –> New –> Project –> Maven –> Maven Module as below then click Next:

Create multiple module project maven eclipse

 

  • Next screen enter value as below then click Next:

Create multiple module project maven eclipse

  • Next screen enter value as below then click Finish:

Create multiple module project maven eclipse

  • You will see ChildModule1 got create in eclipse. Please follow same process to create ChildModule2 project. Once you are done you will see both project in eclipse as below:
  • To add ChildModule1 dependency to ChildModule2 please add below in pom.xml of ChildModule2
<dependencies>
        <dependency>
            <groupId>com.javahonk.ChildModule1</groupId>
            <artifactId>ChildModule1</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
</dependencies>
  • Important: When you are adding dependency to any module its necessary to add version of parent as you could see above. You could repeat same steps if you want to add dependency to other module. For more information please visit maven site here

Leave a Reply

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