How do I create a web application project using maven?
Author: Deron Eriksson
Description: This tutorial describes how to create a web application project using maven.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)


Page: < 1 2

(Continued from page 1)

After executing the command, we can see that the "mywebtest" project has been created by the webapp archetype. If we examine the project, we can see that a webapp directory has been created in src/main. The is the web context directory for the project, and we can see that it contains a WEB-INF directory, which holds a default web.xmlW file.

'mywebtest' project has been created

The project's pom.xml file is shown below. Notice that the packaging is set to "war". This means that if a "mvn package" is performed, a warW file will be built for the project.

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.maventest</groupId>
  <artifactId>mywebtest</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>mywebtest Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>mywebtest</finalName>
  </build>
</project>
Page: < 1 2