Versions Compared

Key

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

Struts 2 provides several Maven Archetypes that create working applications based on a template. archetypes to create complete applications that can be used as the basis of our own applications. Once the archetype project is generated it can be extended to implement our application's functionality.

Table of Contents
minLevel2
styleoutline

Available Archetypes

The following archetypes are available:

The Blank Archetype (struts2-archetype-blank)

Nearly-minimal Struts 2 application, includes only an example package/action and some minimal tests.

The Starter Archetype (struts2-archetype-starter)

...

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

package

The base Java package to use for generated source code. Defaults to archetypeGroupId if not specified. The project will be created a sub-directory named after this parameter.

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

package

(Optional) The base Java package to use for generated source code. Defaults to archetypeGroupId if not specified.

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-to-run Struts project. Just run "mvn install" to build.

Command Quick Reference

These commands are used from the directory created by the archetype plugin.

  • To build
Code Block

   mvn install
  • To create IntelliJ IDEA project files
Code Block

   mvn idea:idea
  • To create Eclipse project files
Code Block

   mvn eclipse:eclipse
  • To run test cases
Code Block

   mvn test
  • To clean up (removes generated artifacts)
Code Block

   mvn clean
  • To package (creates a WAR file)
Code Block

   mvn package
  • To grab necessary JAR files etc.
Code Block

   mvn initialize
  • To run it with Jetty
Code Block

   mvn jetty:run