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.
Open Project Creation Wizard
In the Eclipse IDE, navigate to File -> New -> Other.. to open project creation wizard.
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.
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.
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.
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.
Now you are ready to work on your own Maven Project in Eclipse.