How to Create a New Maven Project in Eclipse

By | October 24, 2020

In this post, We will learn How to Create a New Maven Project in Eclipse

We need to follow the below steps to create a Maven project in Eclipse:

1) Open the Eclipse and Go to File -> New -> Others.

2) Select Maven Project and click on Next.

3) If you do not want to create your maven project on default Workspace then Uncheck the “Use default Workspace location” checkbox option and with the help of the Browse button choose your workspace where you would want to create your Maven project.


4) Select the archetype for this demo just select the ‘maven-aechetype-quickstart‘ and click on Next.

5) Specify the Group Id and Artifact Id and click on Finish.

Note: Here the ‘artifactId‘ is nothing but your project name.

6) Now You can see the maven project is created in Eclipse. Now open the pom.xml file, which resides in the project root directory. By default the POM is generated like this:

7) Look at the default maven project structure

Note: Junit Test cases usually reside under the src -> test -> java > PackageName(com.kkjavatutorials) will only be considered as a test by Maven. The rest of the test cases will be ignored in case if you keep your test cases in some other directory.

8) Modify pom.xml with the latest Junit maven dependencies and save the file.

We have to add these two JUnit Jupiter dependencies in test scope:

  • The junit-jupiter-api (version 5.7.0). This dependency usually provides the public API for writing Junit tests and extensions.
  • The junit-jupiter-engine (version 5.7.0). This dependency basically contains the implementation of the JUnit Jupiter test engine that runs our unit tests.

Run your first Maven Test

1)  To run JUnit Test cases Just Right Click on the pom.xml and go to Run As then Maven test

2) In the console window of Eclipse, you can see the information like this:

3) If you go to JUnit Console then It will display the result of the JUnit test.

That’s all about How to Create a New Maven Project in Eclipse
If you have any feedback or suggestion please feel free to drop in below comment box.

Leave a Reply

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