Struts 2 > Home > Core Developers Guide > Quickstart Using Maven 2
Added by tm_jee, last edited by Ted Husted on Jul 23, 2006  (view change)

Information

This is basically a Struts' maven archetype plugin. It is used to create a working web application template for Struts 2 where the user work build on top of. It is to serve as a little tool for rapid prototyping.

Features

The created template contains :-

  • Sitemesh integration build in
  • A simple Struts action example (both instantiated through Spring and Struts itself)
  • A simple Struts validation example (action and action-alias level)
  • A Simple Struts conversion example (global and action level)
  • A simple Struts resource bundle (both global, action and package level)

Installing Maven archetype for Struts 2

  1. Change directory to the maven archetype directory eg. from Struts' root directory (You will need the Struts 2 source from SVN)
    cd ./struts2-archetype-starter <press enter>
  1. Run the following command to install Struts2 maven archetype into one's local maven repository (typically at ~/.m2/repository where ~ is the user directory)
    mvn install
  1. If "build successful" is shown at the console after execution of the above command, the Struts2 Maven archetype plugin is successfully installed.

Create Struts Web Application Template

To create a workable template:-

  1. Change directory to where the web application template is to be created eg. assuming the directory to be myWebApp.
    mkdir /home/tmjee/myWebApp
        cd /home/tmjee/myWebApp
  1. Run the following command to generate the sample template, assuming:-
    Root Java package com.myCompany.mySystem
    The WAR name myWebApp
    mvn archetype:create -DgroupId=com.myComp.mySystem -DartifactId=myWebApp 
      -DarchetypeGroupId=org.apache.struts -DarchetypeArtifactId=struts2-archetype-starter

Using the created template

Following are some Maven command that might be handy when using the generated template :-

  • To compile
    mvn compile
  • To run test cases
    mvn test
  • To clean up
    mvn clean
  • To package
    mvn package
  • To grab necessary JAR files etc.
    mvn initialize
  • To run it with Jetty6
    mvn jetty6:run