Child pages
  • Create A Spring Web App Using Maven
Skip to end of metadata
Go to start of metadata


This document describes how to create a basic web app using Maven.

Create The Project

Type the following maven command at the command prompt. Replace -DgroupId and -DartifactId with information specific to your group and your project, respectively.

mvn archetype:create -DgroupId=coedu.ucsf.oaais.myaccess.spring -DartifactId=mywebapp -DarchetypeArtifactId=maven-archetype-webapp

Configure Jetty

Now edit the pom.xml file and add the Jetty plugin. Jetty is a HTTP server and javax.servlet container, and the Jetty Maven Plugin allows you to run your project in Jetty using maven.

Add the following XML to the <build> section of pom.xml:


Once you have done that, you can now run your newly created project in Jetty. From the root directory of the project, type:

mvn jetty:run-war

Now check out your app by going to: http://localhost:8080.

Set Up Project In Eclipse

Now that the project has been created, tell maven that this is an Eclipse project.

cd mywebapp
mvn eclipse:eclipse

Note: If you want to use Intellij IDEA, you can do the following:

mvn idea:idea

Documentation on how to set up your project with Intellij and NetBeans can be found on the website: and

Now, import your project into Eclipse:

From Eclipse go to File > Import > Existing Projects into Workspace (under the General category). Select the root directory of your project. Click Finish, and you now have your project set up in Eclipse.

More detailed information about how to fully set up Eclipse for this project can be found on the site:

Build The Project

Now that you have the project set up and ready to go, you will want to build the .war file. To do this you must "install" the app:

mvn install

Once this is complete, you will see a new directory called target an inside of it will be mywebapp.war.

Make the Project a Spring Project

Now that the basics have been covered, let's actually make this project a Spring project by adding the Spring framework dependencies to the pom.xml file.

Clean Up

Before you build a maven project it is always best to clean the project first. To do this just type:

mvn clean
  • No labels