Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Struts provides several Maven Archetypes that create working applications based on a template.

Available Archetypes

The following archetypes are available:

The Starter Archetype (struts2-starter-archetype)

The Starter archetype creates a working web application templatemore featured application using several common technologies used in production applications.

Features

...

  • Sitemesh integration
  • Action example (both instantiated through Spring and Struts itself)
  • Validation example (action and action-alias level)
  • Conversion example (global and action level)
  • Resource bundle (both global, action and package level)

Installing the Archetype

  1. Install Maven 2
  2. Install Subversion
  3. Checkout the Struts 2 source code (svn co http://svn.apache.org/repos/asf/struts/struts2/trunkImage Removed)

The Portlet Archetype (struts2-portlet-archetype)

The Portlet archetype creates a minimally populated JSR 168 portlet.

Features

  • View, Edit, and Help mode examples
  • Simple form for preferences in Edit mode
  • Can be deployed as a servlet or portlet application
  • Can use Maven Jetty plugin to deploy as a servlet webapp

Creating an Application Using an Archetype

...

From a working directory for your project, run the following command:

Code Block
mvn archetype:create   -DgroupId=tutorial \
                       -DartifactId=tutorial \
                       -DarchetypeGroupId=org.apache.struts \
                       -DarchetypeArtifactId=struts2-archetype-starter \
                       -DarchetypeVersion=2.0.2-SNAPSHOT \
                       -DremoteRepositories=http://people.apache.org/repo/m2-snapshot-repository

...

This table describes the parameters used above:

Name

Description

groupId

The id for the group the application belongs to. Usually is the root package for applications in your company, e.g. com.mycompany

artifactId

The id for the project

archetypeGroupId

The group id of the archetype. Will always be org.apache.struts for Struts archetypes

archetypeArtifactId

The id of the archetype

archetypeVersion

The version of the archetype

remoteRepositories

A list of remote repositories that contain the archetype. If deployed to the standard Maven repository or locally, this is optional

The Archetype will create a ready-run Struts project. Just run "mvn install" to build.

Command Quick Reference

  • To build
    Code Block
       mvn install
    

...

  • To grab necessary JAR files etc.
    Code Block
       mvn initialize
    
  • To run it with Jetty6 Jetty
    Code Block
       mvn jetty:run