reset password

Maven Web Application

Create a Maven project in Eclipse. During project creation, choose the Create a simple project option as shown in the screenshot below:

New Maven Project

And on the next screen, fill out Group Id, Artifact Id, and change Packaging to war. You can leave all other fields as is.

After the project is created, add the following to pom.xml (inside <project> and after <packaging>):

  <build>
    <finalName>springmvc</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
      <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>javax.servlet-api</artifactId>
          <version>3.0.1</version>
          <scope>provided</scope>
      </dependency>
      <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>jstl</artifactId>
          <version>1.2</version>
      </dependency>
  </dependencies>

These changes specify that the project requires JDK 1.7 and add the following dependencies:

  • javax.servlet:javax.servlet-api:3.0.1
  • javax.servlet:jstl:1.2

Right click on the project and select Properties -> Project Facets, and change the version of Dynamic Web Module to 3.0 and Java to 1.7.

Right click on the project and select Maven -> Update Project...

[The latest version of Eclipse (i.e. the Mars release) will show an error "web.xml is missing". Don't worry about it as we'll add a web.xml in the next step.]

This page has been viewed 20208 times.