1.下載安裝JDK5或以上版本。
2.下載安裝mysql5.x。
3.下載:apache-maven-2.0.9-bin.zip, 到http://maven.apache.org/download.html上下載。
安裝:將zip解壓到C:/Program Files/Apache Software Foundation中。
設置環境變量:
M2_HOME=C:/Program Files/Apache Software Foundation/apache-maven-2.0.9
PATH中增加%M2_HOME%/bin;
檢測是否安裝成功:
在命令行 執行mvn -version,如果顯示maven版本信息,安裝成功。
4.使用maven下載appfuse
在D盤下建appfuse2文件夾,cd到改文件夾。
執行命令 mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject
maven會下載appfuse到C:/Documents and Settings/你的計算機用戶名/.m2/repository中,速度很慢。你也可以到appfuse官方網站(https://appfuse.dev.java.net/)下載最新版。 你把下載的zip解壓到C:/Documents and Settings/你的計算機用戶名/.m2/repository,maven就不會下載了。
注意:執行mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject命令時,如果你的mysql數據庫已經啓動了,同時root用戶的密碼爲空的話,appfuse會自動在你的數據庫中生成一個myproject的數據庫,
你的root用戶如果有密碼的話,你可以在你創建的項目的文件下的pom.xml中設置一下:找到 <!-- Database settings -->在 <jdbc.password></jdbc.password>中填上密碼。
5.執行mvn jetty:run-war 命令,就可以查看應用了。在ie中輸入http://localhost:8080,可以看到appfuse了。
6.執行mvn appfuse:full-source 命令,此時會報錯。
。。。
[INFO] null
Illegal character in path at index 18: file:/C:/Documents and Settings/Administrator/.m2/repository/org/apache/ant/ant/1.7.0/ant-1.7.0.jar
。。。
這是由於Documents and Settings文件夾有空格的緣故。
將repository文件夾複製到D:/appfuse2下。然後修改C:/Program Files/Apache Software Foundation/apache-maven-2.0.9/conf下的setting.xml文件
- <!-- localRepository
- | The path to the local repository maven will use to store artifacts.
- |
- | Default: ~/.m2/repository
- <localRepository>/path/to/local/repo</localRepository>
- -->
- <localRepository>D:/appfuse2/repository</localRepository>
看清楚了,是增加一行,而不是修改了<localRepository>標籤的內容。
各種配置類型maven所使用的命令:
配置類型 | 命令 |
---|---|
JSF Basic | mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-jsf -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject |
Spring MVC Basic | mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-spring -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject |
Struts 2 Basic | mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject |
Tapestry Basic | mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-tapestry -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject |
JSF Modular | mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-jsf -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject |
Spring MVC Modular | mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-spring -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject |
Struts 2 Modular | mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject |
Tapestry Modular | mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-tapestry -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject |
Core (backend only) |
mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-core -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject |