來自 Maven Archetype 的新應用程式
對於我們這些使用 Maven 作為構建系統的人,我們可以使用 Maven Archetype 來建立一個新的應用程式。
首先查閱 maven 原型目錄
mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/
你可以使用以下一種 achetypes:
空白公約原型(struts2-archetype-convention)
它具有以下功能:
- 基於公約的驗證
- 示例操作
- 包級資源包
- 單元測試
- 谷歌 AppEgine 知道
通過 maven 下載它執行命令
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
空白原型(struts2-archetype-blank)
它具有以下功能:
- 基於 XML 的配置,演示包括其他配置檔案
- 示例操作
- 包級資源包
- 基於 XML 的驗證
- 單元測試
通過 maven 下載它執行命令
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
Starter Archetype(struts2-archetype-starter)
它具有以下功能:
- Sitemesh 整合
- 動作示例(通過 Spring 和 Struts 例項化)
- Spring 整合
- 驗證示例(操作和操作別名級別)
- 轉換示例(全域性和動作級別)
- 資源包(全域性,操作和包級別)
通過 maven 下載它執行命令
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
AngularJS Archetype(struts2-archetype-angularjs)
它具有以下功能:
- 基於會議的行動配置
- 使用 JSON 結果的示例操作
- AngularJS 和 Struts2 整合的示例
通過 maven 下載它執行命令
mvn archetype:generate -B -DgroupId=com.mycompany.mysystem \
-DartifactId=myWebApp \
-DarchetypeGroupId=org.apache.struts \
-DarchetypeArtifactId=struts2-archetype-angularjs \
-DarchetypeVersion=<CURRENT_STRUTS_VERSION> \
-DremoteRepositories=http://struts.apache.org
Portlet Blank Archetype(struts2-archetype-portlet)
它具有以下功能:
-
View, Edit, and Help mode examples
-
編輯模式中的首選項的簡單形式
-
可以部署為 servlet 或 portlet 應用程式
-
可以使用 Maven Jetty 外掛與 pluto 嵌入的配置檔案一起部署(使用’mvn jetty:run -Ppluto-embedded’,然後訪問 http:// localhost:8080 / /pluto/index.jsp)
通過 maven 下載它執行命令
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
Portlet 資料庫原型(struts2-archetype-dbportlet)
它具有以下功能:
-
Uses Spring and Hsql to show a real database query
-
內建快取查詢結果
-
檢視,編輯和幫助模式示例
-
編輯模式中的首選項的簡單形式
-
可以部署為 servlet 或 portlet 應用程式
-
可以使用 Maven Jetty 外掛作為 servlet webapp 進行部署
通過 maven 下載它執行命令
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
外掛原型(struts2-archetype-plugin)
它具有以下功能:
- 示例新結果型別
- 示例基於 XML 的配置
通過 maven 下載它執行命令
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