应用Appfuse3.0.0加速web应用程序的开发

1

 

设置MAVEN环境变量:

MAVEN_HOME=D:\shebeiguanli\apache-maven-3.2.5

PATH=%MAVEN_HOME%\bin

 

2

修改D:\shebeiguanli\maven-2.0.7\conf\settings.xml,

<localRepository>/shebeiguanli/.m2/repository</localRepository>修改为实际的目录

 

3

新建目录test,创建项目

cd E:\appfuse\test

mvn archetype:generate -B -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-tapestry-archetype -DarchetypeVersion=2.1.0-M1 -DgroupId=com.mycompany -DartifactId=myproject

 

mvn archetype:generate -B -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-spring-archetype -DarchetypeVersion=3.0.0 -DgroupId=com.cx.bi -DartifactId=dm -DarchetypeRepository=https://oss.sonatype.org/content/repositories/appfuse

 

4、安装mysql,启动mysql,用户名默认root,密码默认为空,若要修改则修改pom.xml

 

5、引入全部源代码

mvn appfuse:full-source

 

6、生成eclipse项目

mvn eclipse:eclipse

7

编译打包war部署

mvn package  -DskipTests

   

mvn jetty:run-war

 

删除.classpath里的

<classpathentry kind="var" path="M2_REPO/org/springframework/spring/2.0.3/spring-2.0.3.jar"/>

 

eclipse的项目属性,project facetsconvert to facets form,选择dynamic web project

 

访问http://localhost:8080

用户admin/admin

 

8

解压部署

mvn war:inplace

mvn jetty:run

 

9、修改pom.xmlnative2ascii-utf8插件配置

            <resource>

                <directory>src/main/resources</directory>

                <filtering>true</filtering>

                            <excludes> 

                                <exclude>ApplicationResources_el*.properties</exclude>

                                <exclude>ApplicationResources_zh*.properties</exclude>

                                <exclude>ApplicationResources_ko*.properties</exclude>

                            <exclude>displaytag_el*.properties</exclude>

                            <exclude>displaytag_zh*.properties</exclude>

 

                      </excludes>                 

 

10、代码生成

mvn appfuse:gen-model

       //提示要输入表名t_zcxx。结果是生成一个源代码类

      

mvn appfuse:gen -Dentity=Name

       //Name就是上一步生成的类名TZcxx。结果是生成一套源代码类在界面访问

指定表名生成代码:

修改pom.xml:

                <configuration>

                    <!-- Fix annotation detection issue for Java 7. Thanks Shred! -->

                    <!-- http://www.shredzone.de/cilla/page/352/hibernate3-maven-plugin-fails-with-java-17.html -->

                    <componentProperties>

                        <implementation>annotationconfiguration</implementation>

<revengfile>src/test/resources/hibernate.reveng.ftl</revengfile>

                    </componentProperties>

                    <genericCore>${amp.genericCore}</genericCore>

                    <fullSource>${amp.fullSource}</fullSource>

                </configuration>

增加src/test/resources/hibernate.reveng.ftl:
<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE hibernate-reverse-engineering  
  SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >  
  
<hibernate-reverse-engineering>  
<schema-selection match-schema="dm" match-table="sys_login" />
  
    <type-mapping>  
        <!-- jdbc-type is name fom java.sql.Types -->  
        <sql-type jdbc-type="VARCHAR" length='1' hibernate-type="java.lang.String"/>  
        <!-- length, scale and precision can be used to specify the mapping precisly -->  
        <sql-type jdbc-type="NUMERIC" precision='1' hibernate-type="java.lang.Integer"/>  
        <!-- the type-mappings are ordered. This mapping will be consulted last,  
        thus overriden by the previous one if precision=1 for the column -->  
        <sql-type jdbc-type="BIGINT" hibernate-type="java.lang.Integer"/>  
        <sql-type jdbc-type="INTEGER" hibernate-type="java.lang.Integer"/>  
        <sql-type jdbc-type="NUMERIC" hibernate-type="java.lang.Integer"/>  
    </type-mapping>  
  
    <!-- BIN$ is recycle bin tables in Oracle -->  
    <table-filter match-name="BIN$.*" exclude="true"/>  
  
    <!-- Exclude AppFuse tables from all catalogs/schemas -->  
    <table-filter match-name="app_user" exclude="true"/>  
    <table-filter match-name="role" exclude="true"/>  
    <table-filter match-name="user_role" exclude="true"/>  
 
</hibernate-reverse-engineering>

 

参考资料:

http://appfuse.org/display/APF/AppFuse+QuickStart

http://appfuse.org/display/APF/Tutorials

 

你可能感兴趣的:(java,development)