appfuse2.0 to maven

来源:互联网 发布:mvc 网站源码 响应式 编辑:程序博客网 时间:2024/05/22 03:15

下载appfuse2.0源码有两种方法

一种是找到他的cvs下载。

还有一种就是用maven下载,就是appfuse2.0官网上介绍的下载方法。

好了,现在我们开始下载appfuse2.0的源码,用第二钟方法:

1、下载安装 JDK5 或以上版本。

2、下载安装 Mysql5.x 。 

3、建立一个本地的 stmp服务器,或者修改 mail.properties(在 src/main/resources 目录下),使之使用另外一个不同的主机名,它默认是使用的主机名是 "localhost"。(这一步如果不是急需可以先省略,等对appfuse2.0熟悉些了再配置)

4、下载并安装Maven 2.0.6 。这个是必须的。有人问说不下载这个行不行?,我们build时用ant。在appfuse2.0中ant已经不推荐使用了,所以这个是必需的。
                   简单介绍一下maven的使用,在网址http://maven.apache.org/download.html下载maven。

在Windows 2000/XP中使用

  1. 解压 maven-2.0.6-bin.zip到你希望安装Maven 2.0.6的目录下. 例如 C:/Program Files/Apache Software Foundation/maven-2.0.6
  2. 在你的环境变量path中设置maven的路径,  在我的电脑上右键选属性, 选择 "高级" tab, 在 "环境变量" ,新建一个MAVEN_HOME  例如C:/Program Files/Apache Software Foundation/maven-2.0.6。在path中设置%MAVEN_HOME%bin; 。也可以直接在path设置. "C:/Program Files/Apache Software Foundation/maven-2.0.6/bin";%PATH%
  3. 在你的环境变量中, 确认 JAVA_HOME 设置的是你本地的 JDK, 例如 C:/Program Files/Java/jdk1.5.0_02
  4. 打开:开始--运行--敲入cmd。在命令行 执行mvn --version ,如能正确显示maven的版本号,说明maven安装成功。

如果你不喜欢用命令行的话,你也可以在eclipse创建自己的工程,你可以检出 Candy for AppFuse

下面我们就可以下载appfuse2.0了,选择你熟悉mvc,我下载的是Struts 2 Basic,

我在D:创建一个文件夹appfuse2-hzy,

例如D:/appfuse2-hzy/

命令行中输入 mvn archetype:create -DarchetypeGroupId=org.appfuse -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/repository -DarchetypeVersion=2.0 -DgroupId=com.mycompany.app -DartifactId=myproject

这时maven就开始创建项目了,maven首先在C:/Documents and Settings/你的计算机用户名/.m2/repository下载appfuse2.0所需要的jar文件,这是一个漫长的等待过程。如果你的网速极快,你可以等下去。在appfuse.java.net网站中appfuse作者已经给我们准备好appfuse-2.0-rc1-dependencies.zip,你只要把它解压到C:/Documents and Settings/你的计算机用户名/.m2/repository目录里面maven检测到就不用下载了。

下面是各种配置类型maven所使用的命令:


配置类型 命  令 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 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 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 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 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 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 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 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 Core
(仅后端) 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
在maven执行mvn archetype:create -DarchetypeGroupId=org.appfuse -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/repository -DarchetypeVersion=2.0 -DgroupId=com.mycompany.app -DartifactId=myproject 时,如果你的mysql数据库已经启动了,同时root用户的密码为空的话,appfuse会自动在你的数据库中生成一个myproject的数据库,
你的root用户如果有密码的话,你可以在你创建的项目的文件下的pom.xml中设置一下   <!-- Database settings -->
  root
        添加密码

要运行 AppFuse 现在已经很容易了,一旦建立了项目原型,Maven会用hibernate3和dbunit的插件创建和生成数据库。现在你要做的就是用 Maven 运行 Jetty,然后查看你的工程。

1、 在命令行下,cd 到你的工程目录下,运行 mvn ,这个命令会完成相关 jar 包和 Tomcat 的下载,运行你的工程的集成测试。上面的命令大概需要5-10分钟。

2、在你的工程目录下运行 mvn jetty:run-war ,你就可以去查看你的工程了。Maven 会启动 Jetty,这样的话,你就可以用这个地址: http://localhost:8080在你的浏览器中查看你的工程了。(如果你使用的是模块化原型,你需要在你的工程的 web 目录下运行 mvn jetty:run-war 。)
管理员的默认用户名/密码为 admin/admin ,普通用户的话,可以用 user/user 登录。
运行成功之后,你可能会打开appfuse的src查看源码
发现src/main/java/com/hzy/app只有一个App.java再也没别的文件了,不要着急。我们接着执行如下命令mvn appfuse:full-source.现在你终于可以看到appfuse2.0的源码了,哈哈.在项目的src/main/java/下会多出一个 org的文件,一步步进去
你会源码就在这里。

开发你的项目

你可以用 Eclipse, IDEA 或 NetBeans开发你的项目。 打算用Eclipse, 在dos中执行 mvn eclipse:eclipse 生成eclipse项目信息的文件. 用IDEA, 执行 mvn idea:idea

 
 
原创粉丝点击