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

You May Also Like:

What is Maven?
How to install and setup Maven Environment on windows?
Create a maven project using the command line
How to import the maven project in Eclipse?
How to create a maven web application project in Eclipse
How to create a multi-module project using maven?
How to Fix missing src/main/java & src/test/java folders in the Eclipse Maven web Project?
How to create user-defined properties in Maven?
What is the maven local repository location & how to change it?
How to add or update the maven settings.xml file in eclipse?
Importing maven remote Archetype Catalogs in eclipse ?
What is POM in the maven Project?
What is Super POM in Maven Project?
Understanding the purpose of Maven Plugin
Compiling the Maven project with different JDK versions? 
Understanding of settings.xml in maven
How to enable a proxy setting in Maven?
Maven Dependency Scopes
How to generate javadoc in the maven Project
How to create a runnable JAR file with Maven?
How to add local jar files to a Maven project?
How to convert an existing Java Project to Maven in Eclipse?
How to exclude dependency in maven?
Managing External Dependencies in maven
Understanding of Maven Repositories
What is an archetype in Maven?
Snapshot Vs Version in maven
Apache Maven – Profiles

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.