Versions Compared

Key

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

Information

This is basically a Struts' maven archetype plugin. It is used to create The Struts Maven Archetype creates 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

...

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

Installing

...

  1. Change directory to the maven archetype directory eg. from Struts' root directory (You will need the Struts 2 source from SVN)
    Code Block
    
       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)
    Code Block
    
       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.
    Code Block
    
        mkdir /home/tmjee/myWebApp
        cd /home/tmjee/myWebApp
    

...

Root Java package

com.myCompany.mySystem

The WAR name

myWebApp

...

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 Added)

Creating an Applicatoin

From a working directory for your project:

Code Block

mvn archetype:create -DgroupId=tutorial \
                       -DartifactId=tutorial \
                       

...

-DarchetypeGroupId=org.apache.struts \
                       -DarchetypeArtifactId=struts2-archetype-starter \

...

                       -DarchetypeVersion=1.0-SNAPSHOT \

(tick) Substitute the name of your project for "tutorial". Substitute your own package name for "org.apache.struts".

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

Command Quick Reference

  • To build

Using the created template

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

  • To compile
    Code Block
       mvn compileinstall
    
  • To run test cases
    Code Block
       mvn test
    

...