How to create a maven web application project in Eclipse

By | October 25, 2020

In this post, We will learn How to create a maven web application project in Eclipse

Follow the below steps to create a maven web application project in Eclipse:

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

2: In the opened New wizard, scroll down and select Maven->Maven Project, click Next

3: In the below screen, If you do not want to create your maven project on the default Workspace location 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. Click on Next.

4: Just scroll down and select option with Artifact Id as maven-archetype-webapp and Click on Next

5: Now provide Group Id, Artifact Id & version. These attributes basically give your project deliverable(jar/war/ear etc.. ) a unique identity in the repository. Click Finish

5: Your project structure should like the below one.

Note: In case if you do not see the src/main/java and src/test/java directories in your project structure then you will have to go to Project ->Properties ->Java BuildPath ->Libraries after that select JRE System Library and click on Edit and Select or configure correct JRE System Library click on Finish and then click on Apply. You should see those( src/main/java and src/test/java) folders/directories now. You may also right-click on your project then maven -> Update Project->Ok to perform a maven-update on your project.

Note: You should keep in mind that in recent Eclipse versions you don’t need to use mvn eclise:eclipse anymore because this functionality is now built-in with the recent m2e eclipse plugin

6: Finally, You will have to update your pom.xml based on your project requirement (adding dependencies, profiles, plugins, repositories etc..)

Below pom.xml is by default generated by our Project:

The dependency section refers to the library on your project is relying upon. These libraries can be found on different maven repositories.

For instance, if your code is using Servlet API and your test cases rely upon JUnit Jupiter, your pom.xml will include the dependency for Servlet API and JUnit Jupiter like below:

That’s all about How to create a maven web application 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 New Maven 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. Required fields are marked *