Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add generate commands for each archetype

...

Table of Contents
minLevel2
maxLevel3
outlinetrue
indent1em
stylenone

Available Archetypes

The Blank Convention Archetype (struts2-archetype-convention)

Features

  • Convention-based validation
  • Example actions
  • Package-level resource bundle
  • Unit-testing
  • Google AppEgine aware
Code Block

mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \
							-DartifactId=myWebApp \
							-DarchetypeGroupId=org.apache.struts \
							-DarchetypeArtifactId=struts2-archetype-convention \
							-DarchetypeVersion=<CURRENT_STRUTS_VERSION> \
							-DremoteRepositories=http://struts.apache.org

The Blank Archetype (struts2-archetype-blank)

Excerpt Include
WW:Struts 2 Blank Archetype
WW:Struts 2 Blank Archetype
nopaneltrue

See the Struts 2 Blank Archetype page for more information, including some basic Maven information, how to build and run the app, and basic application information.

Code Block

mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \
							-DartifactId=myWebApp \
							-DarchetypeGroupId=org.apache.struts \
							-DarchetypeArtifactId=struts2-archetype-blank \
							-DarchetypeVersion=<CURRENT_STRUTS_VERSION> \
							-DremoteRepositories=http://struts.apache.org

The Starter Archetype (struts2-archetype-starter)

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

Features

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

mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \
							-DartifactId=myWebApp \
							-DarchetypeGroupId=org.apache.struts \
							-DarchetypeArtifactId=struts2-archetype-starter \
							-DarchetypeVersion=<CURRENT_STRUTS_VERSION> \
							-DremoteRepositories=http://struts.apache.org

The Portlet Blank Archetype (struts2-archetype-portlet)

The Portlet blank 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 with the pluto-embedded profile (usage 'mvn jetty:run -Ppluto-embedded', then access http://localhost:8080/<artifactId>/pluto/index.jsp)
Code Block

mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \
							-DartifactId=myWebApp \
							-DarchetypeGroupId=org.apache.struts \
							-DarchetypeArtifactId=struts2-archetype-portlet \
							-DarchetypeVersion=<CURRENT_STRUTS_VERSION> \
							-DremoteRepositories=http://struts.apache.org

The Portlet Database Archetype (struts2-archetype-dbportlet)

The Portlet database archetype creates a simple JSR 168 portlet that displays the contents of a database table.

Features

  • Uses Spring and Hsql to show a real database query
  • Builtin caching of query results
  • 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

The Blank Convention Archetype (struts2-archetype-convention)

Features

...

Code Block

mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \
							-DartifactId=myWebApp \
							-DarchetypeGroupId=org.apache.struts \
							-DarchetypeArtifactId=struts2-archetype-dbportlet \
							-DarchetypeVersion=<CURRENT_STRUTS_VERSION> \
							-DremoteRepositories=http://struts.apache.org

...

The Plugin Archetype (struts2-archetype-plugin)

...

  • Example new result type
  • Example XML-based configuration
Code Block

mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \
							-DartifactId=myPlugin \
							-DarchetypeGroupId=org.apache.struts \
							-DarchetypeArtifactId=struts2-archetype-plugin \
							-DarchetypeVersion=<CURRENT_STRUTS_VERSION> \
							-DremoteRepositories=http://struts.apache.org

Creating an Application Using a Maven Archetype

...

Code Block
mvn archetype:generate -B \
                       -DgroupId=tutorial \
                       -DartifactId=tutorial \
                       -DarchetypeGroupId=org.apache.struts \
                       -DarchetypeArtifactId=struts2-archetype-blank \
                       -DarchetypeVersion=<version>=<CURRENT_STRUTS_VERSION>
		       -DremoteRepositories=http://struts.apache.org

where <version> <CURRENT_STRUTS_VERSION> is archetype's version you want to use, eg. 2.3.215.1

Staging repository

If the above command will fail because of missing archetypes in central repository, you can try to use staging repository like below

...