码家

Web Platform, Cloud and Mobile Application Development

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

  AppFuse 是一个开源项目,主要目的是使用开源工具来帮助开发者快速有效的建立Web应用项目。使用AppFuse可以减少开发人员在建立新web应用时候花费大量时间在项目结构的建立上。 最核心的是, AppFuse是一个项目的骨架,类似图使用IDE的向导方式来创建web项目。
AppFuse 2 的环境配置:
 a. 安装JDK 5+ (确保JAVA_HOME 指向JDK目录, 而不是JRE目录).
 b. 安装 MySQL 5.x.
 c. 建立本地SMTP服务或者修改mail.properties (在src/main/resources) 的use为一个不同的主机名- it 缺省是 "localhost".
 d. 安装Maven 2.0.9+.
    因为AppFuse 2使用了Maven 2 的支持。一般的Maven2 会再你使用AppFuse的包的时候会下载这些包,但是如果你的网络不好的话。你也可以自己下载AppFuse2的依赖包,其下载地址为:https://appfuse.dev.java.net/servlets/ProjectDocumentList?folderID=9173&expandFolder=9173&folderID=9173,现在版本是AppFuse2.02.大小为80M多。
然后解压到某个文件夹下,然后修改Maven_Home下的/conf/settings.xml里的相应配置,设置本地资源库。 
<!-- localRepository
    The path to the local repository maven will use to store artifacts.
    Default: ~/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <localRepository>E:/appfusedeps/repository</localRepository>

需要注意的上面的配置里说默认的资源库路径为~/.m2/repository,这是指用户的home目录,但如果这样设置在windows下,会产生一些问题,因为windows的用户目录在C:\Documents and Settings下,而这个目录有空格,所以最好直接指定另外的没有空格的英文路径。

 下面是创建不同种类项目的Archetype Command:
1.JSF Basic 
   mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-jsf -DremoteRepositories=http://static.appfuse.org/releases-DarchetypeVersion=2.0 -DgroupId=com.mycompany.app -DartifactId=myproject 
2.Spring MVC Basic 
  mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-spring -DremoteRepositories=http://static.appfuse.org/releases-DarchetypeVersion=2.0 -DgroupId=com.mycompany.app -DartifactId=myproject 
3. Struts 2 Basic 
  mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/releases-DarchetypeVersion=2.0 -DgroupId=com.mycompany.app -DartifactId=myproject 
4. Tapestry Basic 
  mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-tapestry -DremoteRepositories=http://static.appfuse.org/releases-DarchetypeVersion=2.0 -DgroupId=com.mycompany.app -DartifactId=myproject 
5. JSF Modular 
  mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-jsf -DremoteRepositories=http://static.appfuse.org/releases-DarchetypeVersion=2.0 -DgroupId=com.mycompany.app -DartifactId=myproject 
6.Spring MVC Modular 
  mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-spring -DremoteRepositories=http://static.appfuse.org/releases-DarchetypeVersion=2.0 -DgroupId=com.mycompany.app -DartifactId=myproject 
7.Struts 2 Modular 
  mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-struts -DremoteRepositories=http://static.appfuse.org/releases-DarchetypeVersion=2.0 -DgroupId=com.mycompany.app -DartifactId=myproject 
8.Tapestry Modular 
  mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-tapestry -DremoteRepositories=http://static.appfuse.org/releases-DarchetypeVersion=2.0 -DgroupId=com.mycompany.app -DartifactId=myproject 
9.Core(backend only)
   mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-core -DremoteRepositories=http://static.appfuse.org/releases-DarchetypeVersion=2.0 -DgroupId=com.mycompany.app -DartifactId=myproject
下面将举一个例子:
1. 在D盘创建一个目录D:\projects\
2. 启动cmd。进入目录D:\projects\.
3.执行如下建构命令创建基本的:
mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteReposities=http://static.appfuse.org/release -Darchetypeversion=2.0.1 -DgroupId=com.zhangjr.framework -DartifactId=myproject
4.执行结束后将会看到D:\projects\myproject目录结构,编辑D:\projects\myproject\pom.xml,修改mysql数据连接信息,主要是修改root的密码为你自己数据库用户密码
因为缺省为空<jdbc.password></jdbc.password>。
5.在cmd中进入目录D:\projects\myproject
6.执行mvn jetty:run-war
7.等执行结束后,在浏览器地址栏输入http://localhost:8080/,你将会看到项目的界面,任意输入一个用户名和密码即可登入。

8.登入进去以后,不错吧。你的新项目不写一行代码就完成了吧。呵呵。

9.你可以运行mvn appfuse:full-source,则会创建数据库,并且生成代码。

posted on 2013-04-11 09:40  海山  阅读(693)  评论(0编辑  收藏  举报