Maven – Create a Simple Webapp Project

1. Create a new Maven project in Eclipse with war as the packaging type


2. Edit the pom.xml as follow

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
	<name>Spring MVC Trial</name>
	<description>Spring MVC Trial</description>
	<!-- Build Configuration -->


3. Create /src/main/webapp/index.jsp

<head><title>Example :: Spring Application</title></head>
	<h1>Example - Spring Application</h1>
	<p>This is my test.</p>


4. Create /src/main/webapp/WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?>


5. Run Maven Install


6. A .war file is built at /target and copy it to the Tomcat webapp folder


7. Verify the deployment in browser


Done =)


19 thoughts on “Maven – Create a Simple Webapp Project”

  1. Can you explain how you installed the maven plugin on eclipse ?
    I’m trying to install it but I do not understand how to do it …


      1. Thank you for this help. I actually already had Maven (m2eclipse) installed. I am lost on how to use it from within Eclipse. Or, if from the command line, which commands to run.


      2. a maven project contains different life cycle phases. for example, if you want to run test cases, you can run the
        mvn test

        if you want to build the project
        mvn install

        the install phase will include the package and test phases etc.

        for more information about the maven command, you can take a look @
        Maven Getting Started Guide

        If you are new to Maven, the following book is really a nice start for you
        Sonatype – Maven: The Complete Reference

        Hope it can help you to start maven. it is really a great tool for java development. =)


  2. I am sorry for this newbie question. at step 5 and 6 it says /target folder… where is /target folder. Please help


      1. Thank you for your reply, actually I found the war file also, I done all the steps as you told but when I deploy it to tomcat that is I copy the war file to webapp of tomcat and run the tomcat, when hitting the same URL it says HTTP Status 404. please help me


      2. The path where I put the war file in the tomcat
        C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.