The Struts 2 Blank Archetype (“blank-archetype”) provides a minimal, but complete, Struts 2 application. It demonstrates some of the most basic Struts 2 concepts.
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)
Run the following command from your new project’s parent directory. The project will be created in a sub-directory named after the artifactId parameter.
The first two parameters, groupId and artifactId, should be set according to your needs:
groupId This should be the root package of your application, e.g., com.mycompany.myapp.
artifactId Names the project directory that will be created in the current directory.
Struts 2 Maven Archetypes
Struts 2 provides several Maven archetypes that create a starting point for our own applications.
Quickstart
A recommended way to start with Struts2 archetypes is to use
archetype:generategoal withfilterparameter.Available Archetypes
The Blank Convention Archetype (struts2-archetype-convention)
Features
Convention-based validation
Example actions
Package-level resource bundle
Unit-testing
Google AppEgine aware
The Blank Archetype (struts2-archetype-blank)
The Struts 2 Blank Archetype (“blank-archetype”) provides a minimal, but complete, Struts 2 application. It demonstrates some of the most basic Struts 2 concepts.
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)
The AngularJS Archetype (struts2-archetype-angularjs)
Features
Convention-based Action Configuration
Example actions with JSON Result
Example for AngularJS and Struts2 Integration
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)
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 Plugin Archetype (struts2-archetype-plugin)
Features
Example new result type
Example XML-based configuration
Creating an Application Using a Maven Archetype
Run the following command from your new project’s parent directory. The project will be created in a sub-directory named after the
artifactIdparameter.The first two parameters,
groupIdandartifactId, should be set according to your needs:groupIdThis should be the root package of your application, e.g., com.mycompany.myapp.artifactIdNames the project directory that will be created in the current directory.Staging repository
If the above command will fail because of missing archetypes in central repository, you can try to use staging repository.
Add staging repository to your settings.xml
Use
stagingprofile in the command.Archetype Parameters
The
-Boption runsarchetype:generatein batch mode; it avoids a prompt to confirm our settings.Command Quick Reference
These commands are used from the directory created by the archetype plugin (the project’s sub-directory that was created in the previous step).