How to Create a Web Project Using Maven in Eclipse

In a previous article, we have discussed how to create a simple maven project in eclipse. In this article, we will show you how to create a web project or application using maven in Eclipse IDE.
Let me list out what are tools and technologies that I have used to create a web project or application using maven in Eclipse IDE.

Tools and technologies used

  • IDE - Eclipse Neon
  • JDK - 1.8
  • Maven - 3.5.3
  • Apache Tomcat - 8.5
  • Servlet API - 3.1.0
Let’s start step by step to create a web project using Maven in Eclipse IDE.


  • Open Eclipse
  • Click on File -> New -> Maven Project


  • Don't select a simple project as shown in below diagram
  • Select default Workspace location
  • Click on Next 


Select the Maven archetype as maven-archetype-webapp and click on next.


Provide GroupId, ArtifactId, package and click on finish.
  • GroupId: net.javaguides.maven-web-project
  • Artifact Id: MavenWebApp
  • package: net.javaguides.maven_web_project 


And you are all set. You should see a new Project in Eclipse with below structure.

Now, let's test this web project by adding simple Servlet and deploy on tomcat server.


Open pom.xml file and add servlet API dependency and maven compiler plugin as:
    <name>MavenWebApp Maven Webapp</name>
        <!-- -->
        <!-- -->


Now create a SimpleServlet class under net.javaguides.mavenwebapp package and write the following code in it.
package net.javaguides.mavenwebapp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

 * Servlet implementation class SimpleServlet
public class SimpleServlet extends HttpServlet {

   private static final long serialVersionUID = 1L;

   protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
         throws ServletException, IOException {
      resp.getWriter().write("Hello World! Maven Web Project Example.");


Let's Build the project using the following maven command.- mvn clean install

To execute the about maven command in Eclipse IDE, Click on Run menu → Run Configuration.. to create a new configuration.

In Run Configuration Wizard, double-click on Maven Build and provide the configuration information (Name, Base directory and Goals) as shown in the below image.

Now click on the Run and monitor the output in console.


Let's deploy our web project into tomcat. Let's first configure tomcat server in Eclipse IDE via server section. Once deployment is a success then Open a browser and type http://localhost:8080/hello URL in address bar.
That's all. I hope you understood the flow of creating a web project using Maven in Eclipse. Do comment if you need any help or issues.