mavenでStruts2プロジェクトを作る


# mavenのバージョン。

	$ mvn -v
	Apache Maven 3.0.3 (r1075438; 2011-03-01 02:31:09+0900)
	Maven home: /usr/share/maven
	Java version: 1.7.0_12-ea, vendor: Oracle Corporation
	Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_12.jdk/	Contents/Home/jre
	Default locale: ja_JP, platform encoding: UTF-8
	OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"

# 作る

	$ mkdir struts2 && cd struts2
	$ mvn archetype:generate
	[INFO] Scanning for projects...
	Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
	Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom (5 KB at 8.3 KB/sec)
	:
	:
	829: remote -> sk.seges.sesam:sesam-annotation-archetype (-)
	830: remote -> tk.skuro:clojure-maven-archetype (A simple Maven archetype for Clojure)
	831: remote -> uk.ac.rdg.resc:edal-ncwms-based-webapp (-)
	Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 296: 

↑まで来たら、"struts2"って入力 + enter。

	Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 296: struts2
	Choose archetype:
	1: remote -> com.jgeppert.struts2.jquery:struts2-jquery-archetype-base (This Archetype provides a Webapp Configuration ready for the Struts2 jQuery Plugin.)
	2: remote -> com.jgeppert.struts2.jquery:struts2-jquery-archetype-mobile (This Archetype provides a Webapp Configuration ready for the Struts2 jQuery Mobile Plugin.)
	3: remote -> com.jgeppert.struts2.jquery:struts2-jquery-bootstrap-archetype-grid (This Archetype provides a Webapp Configuration ready for the Struts2 jQuery Grid Plugin and the Struts2 Bootstrap Plugin.)
	4: remote -> org.apache.struts:struts2-archetype-blank (-)
	5: remote -> org.apache.struts:struts2-archetype-convention (-)
	6: remote -> org.apache.struts:struts2-archetype-dbportlet (-)
	7: remote -> org.apache.struts:struts2-archetype-plugin (-)
	8: remote -> org.apache.struts:struts2-archetype-portlet (-)
	9: remote -> org.apache.struts:struts2-archetype-starter (-)
	Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 9 # ← starterを選んだ

次にバージョンを聞かれるから。最新のを選ぶ。新しいのが好きだから。

	Choose org.apache.struts:struts2-archetype-starter version: 
	1: 2.0.11.2
	2: 2.2.1
	3: 2.2.1.1
	4: 2.3.7
	5: 2.3.8
	6: 2.3.12
	7: 2.3.14
	8: 2.3.14.1
	9: 2.3.14.2
	10: 2.3.14.3
	11: 2.3.15
	12: 2.3.15.1
	Choose a number: 12: 12

groupId・artifactId・version・packageを設定する。

>グループ Id（groupId）はプロジェクトを一意に識別する名前で、プロジェクトのルートパッケージ名を指定するのが一般的です。
> アーティファクト Id（artifactId）はプロジェクトの成果物の名前です。JARやWARにつける名前を指定してください。
http://d.hatena.ne.jp/Kishi/20090228/1235813480

	Define value for property 'groupId': : com.yujiroarai.java.struts2 # 
	Define value for property 'artifactId': : helloworld
	Define value for property 'version':  1.0-SNAPSHOT: : 
	Define value for property 'package':  com.yujiroarai.java.struts2: : 

最後に設定を確認後、"Y"を入力して作成実行。

	Confirm properties configuration:
	groupId: com.yujiroarai.java.struts2
	artifactId: helloworld
	version: 1.0-SNAPSHOT
	package: com.yujiroarai.java.struts2
	 Y: : Y
	[INFO] ----------------------------------------------------------------------------
	[INFO] Using following parameters for creating project from Archetype: 	struts2-archetype-starter:2.3.15.1
	[INFO] ----------------------------------------------------------------------------
	[INFO] Parameter: groupId, Value: com.yujiroarai.java.struts2
	[INFO] Parameter: artifactId, Value: helloworld
	[INFO] Parameter: version, Value: 1.0-SNAPSHOT
	[INFO] Parameter: package, Value: com.yujiroarai.java.struts2
	[INFO] Parameter: packageInPathFormat, Value: com/yujiroarai/java/struts2
	[INFO] Parameter: package, Value: com.yujiroarai.java.struts2
	[INFO] Parameter: version, Value: 1.0-SNAPSHOT
	[INFO] Parameter: groupId, Value: com.yujiroarai.java.struts2
	[INFO] Parameter: artifactId, Value: helloworld
	[INFO] project created from Archetype in dir: /Users/yujiroarai/	workspace/java/struts2/helloworld
	[INFO] ------------------------------------------------------------------------
	[INFO] BUILD SUCCESS
	[INFO] ------------------------------------------------------------------------
	[INFO] Total time: 2:40.764s
	[INFO] Finished at: Tue Sep 10 21:56:07 JST 2013
	[INFO] Final Memory: 9M/142M
	[INFO] ------------------------------------------------------------------------

できた。

````
* tree helloworld
helloworld
├── pom.xml
├── src
│   ├── main
│   │   ├── java
│   │   │   └── com
│   │   │       └── yujiroarai
│   │   │           └── java
│   │   │               └── struts2
│   │   │                   ├── DateConverter.java
│   │   │                   ├── HelloWorldAction.java
│   │   │                   └── IndexAction.java
│   │   ├── resources
│   │   │   ├── applicationContext.xml
│   │   │   ├── com
│   │   │   │   └── yujiroarai
│   │   │   │       └── java
│   │   │   │           └── struts2
│   │   │   │               ├── globalmessages.properties
│   │   │   │               ├── log4j.properties
│   │   │   │               ├── struts.properties
│   │   │   │               └── xwork-conversion.properties
│   │   │   └── struts.xml
│   │   └── webapp
│   │       ├── WEB-INF
│   │       │   ├── decorators
│   │       │   │   └── main.jsp
│   │       │   ├── decorators.xml
│   │       │   ├── dwr.xml
│   │       │   ├── sitemesh.xml
│   │       │   └── web.xml
│   │       ├── index.jsp
│   │       ├── jsp
│   │       │   ├── helloWorld.jsp
│   │       │   └── index.jsp
│   │       └── styles
│   │           ├── forms.css
│   │           ├── layout-1col.css
│   │           ├── layout-navleft-1col.css
│   │           ├── layout-navleft-2col.css
│   │           ├── layout-navtop-1col.css
│   │           ├── layout-navtop-3col.css
│   │           ├── layout-navtop-localleft.css
│   │           ├── layout-navtop-subright.css
│   │           ├── layout.css
│   │           ├── main.css
│   │           ├── nav-horizontal.css
│   │           ├── nav-vertical.css
│   │           ├── tools.css
│   │           └── typo.css
│   └── test
│       └── java
│           └── com
│               └── yujiroarai
│                   └── java
│                       └── struts2
│                           ├── HelloWorldActionTest.java
│                           └── IndexActionTest.java
└── target
    ├── classes
    │   ├── applicationContext.xml
    │   ├── com
    │   │   └── yujiroarai
    │   │       └── java
    │   │           └── struts2
    │   │               ├── DateConverter.class
    │   │               ├── HelloWorldAction.class
    │   │               ├── IndexAction.class
    │   │               ├── globalmessages.properties
    │   │               ├── log4j.properties
    │   │               ├── struts.properties
    │   │               └── xwork-conversion.properties
    │   └── struts.xml
    ├── m2e-wtp
    │   └── web-resources
    │       └── META-INF
    │           ├── MANIFEST.MF
    │           └── maven
    │               └── com.yujiroarai.java.struts2
    │                   └── helloworld
    │                       ├── pom.properties
    │                       └── pom.xml
    └── test-classes
        └── com
            └── yujiroarai
                └── java
                    └── struts2
                        ├── HelloWorldActionTest.class
                        └── IndexActionTest.class
````