New Maven Project in Eclipse

 

We have seen Maven which is specifically used for building and managing any Java-based projects. With this tutorial we will have a look at “How to Create New Maven Project in Eclipse ?”


Maven projects have a consistent structure of project, and it is possible to create this structure automatically in eclipse.

  1. Open Project Creation Wizard

    In the Eclipse IDE, navigate to File -> New -> Other.. to open project creation wizard.

    Create Maven Project _File _New _Other

  2. Select Maven Project

    In the project creation wizard, type Maven as filter. Then select Maven Project wizard to start creation of new project with Maven.

    Apache Maven Create Project Start

  3. New Maven Project

    You can choose to Create a simple project (skip archetype selection). Here, we will choose the simple maven project. This will create a simple, maven enabled java project. Leave the other options as it is, and click Next.

    Note : If you want to do more advanced setup, leave the option “Create a simple Project” unchecked. You will have a screen with more advanced features to setup maven project.

    New Maven Project Name

  4. Configure Maven Project

    Enter the project related information to configure maven project. You have to enter following maven coordinates to complete the basic configuration of maven project. Refer.

    • Group Id – This should be unique amongst an organization or a project. Like Organization name or site name.
    • Artifact Id – This should corresponds to the name of the project.
    • Version – This is used to maintain the code changes as version numbers.
    • Packaging – This is used to provide a type of packaging for project files. This can be values like jar, war or pom.

     

    This is a standalone project which does not have any parent dependencies. Leave the Parent Project section as it is and click Finish.

    Note : In case of multi-module maven project this will help to configure the parent-child mapping of maven projects.

    Configure Maven Project in Eclipse

  5. View Maven Project Structure

    Your new Maven Project is created in eclipse. You will have following structure to place your code.

    • /src/java/main – to place java source code.
    • /src/java/resources – to place resources required for java code.
    • /src/test/java – to place java source for testing.
    • /src/test/resources – to place resources for testing code.

     

    Find below is the image for Project Structure.

    Maven Project Structure in Eclipse

    Now you are ready to work on your own Maven Project in Eclipse.

Advertisement

One thought on “New Maven Project in Eclipse

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.