Servlet Project in Maven

Servlet Project in Maven

Posted in : Java Posted on : May 25, 2012 at 6:41 PM Comments : [ 0 ]

In this tutorial you will learn how to build servlet project in maven

Servlet Project in Maven

At first download and install the maven in your computer

Then open the command prompt and go to the location where you want to creat project and then type the following

You will see the messages as

Select "18: internal -> maven-archetype-webapp (A simple Java web application)" as

groupId- It identifies the project uniquelly across all the project, therefore we should follow the naming scheme.
Example- com.devmanuals.myproject.servlet
artifactId- This specifies the name of you jar file without specifying its version. while creating the project you shoud specify the jar file name.
Example- my-first-servlet-example.
SNAPSHOT - It is special version in maven which is indicates the latest code. It automatically grabs the recent code you buit for your project.
package - is the package of the project.
press Y for creating the project.

You will see the following project structure

When you will open the myproject servlet you will find pom.xml. This specifies your project configuration, such as compiler plugin, dependencies ect.

<project xmlns="" xmlns:xsi=""
	<name>myservlet Maven Webapp</name>

Now add the following dependencies for servlet


Now make a directory named java im main directory and write your java classes their. To compile your application type the following command

You will see the message "BUILD SUCCESSFUL" for successfully compilation of your project.

You can download sample java project from here

Go to Topic «PreviousHomeNext»

Your Comment:

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image

Tutorial Topics