`
aaagu1234
  • 浏览: 144907 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Appfuse2开发流程_技术中心

阅读更多
[size=medium]Appfuse2开发流程
2008年05月20日 星期二 下午 05:48
學習了Appfuse2一些時間,把自己使用appfuse2開發項目的方法流程總結一下。也希望大家可以给予意见指点一下……
1、創建工程(這里用的是Struts2),命令為:
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

2、修改數據庫連線信息(我用的是mysql),進入myproject底下打開pom.xml文件,修改連線帳號密碼

xml 代码
<dbunit.dataTypeFactoryName>org.dbunit.dataset.datatype.DefaultDataTypeFactorydbunit.dataTypeFactoryName>   
        <dbunit.operation.type>CLEAN_INSERTdbunit.operation.type>   
        <hibernate.dialect>org.hibernate.dialect.MySQLInnoDBDialecthibernate.dialect>   
        <jdbc.groupId>mysqljdbc.groupId>   
        <jdbc.artifactId>mysql-connector-javajdbc.artifactId>   
        <jdbc.version>5.0.5jdbc.version>   
        <jdbc.driverClassName>com.mysql.jdbc.Driverjdbc.driverClassName>   
        <jdbc.url>jdbc.url>   
        <jdbc.username>wensonjdbc.username>   
        <jdbc.password>wensonjdbc.password>   

3、設置解決中文顯示問題,防止出現亂碼,詳情請參考:http://wenson.javaeye.com/blog/138633

4、下載源代碼。在命令控制臺進入myproject目錄,執行命令:mvn appfuse:full-source,進行源碼下載

5、試運行所建項目。執行命令:mvn jetty:run-war,運行項目。運行成功后在瀏覽器里使用http://localhost:8080即可訪問

6、下面開始創建新的模塊。一般模塊的設計創建有兩種方式,一種是先設計數據庫,再根據數據庫生成pojo,一種是先生成pojo,再根據pojo生成數據庫。appfuse都支持這兩種方式。先使用mvn eclipse:eclipse 命令生成eclipse的項目配置文件,把項目導入到eclipse中。如果用先設計數據庫的方式的話,那么在原先生成的數據中新增數據表,設計好表結構,然后在控制臺執行mvn appfuse:gen-model命令,就會自動生成對應的pojo,然后執行mvn appfuse:gen Dentity=pojoName,即可自動生成dao、service等類。如果使用先生稱pojo類的方式,那么在com.company.model底下先新建一個pojo,使用JPA設置好數據庫映射,然后執行mvn appfuse:gen Dentity=pojoName,即可自動生成dao、service等類。

(提示:AppFuse 制作了一个代码生成工具 ,他生成的代码位于 \target\appfuse\ 目录下面generated-sources内。代码生成工具可以生成绝大部分我们需要的代码,比如 dao 类,service 类,菜单、增删改的 web 页面、配置文件、样本数据,等等。

如果你希望appfuses生成 dao 和 service 类,就在项目根目录下的pom.xml中,把genericCore属性设为false。

xml 代码
<project>  ...    <build>      <plugins>        <plugin>          <groupId>org.codehaus.mojo</groupId>          <artifactId>appfuse-maven-plugin</artifactId>          <version>2.0</version>          <configuration>            <genericCore>true</genericCore> <!-- Set to false if you want Java files generated for your DAOs and Managers -->            <fullSource>false</fullSource> <!-- Set to true if you've "full-sourced" your project and changed org.appfuse to your package name -->          </configuration>          <dependencies>            <dependency>              <groupId>${jdbc.groupId}</groupId>              <artifactId>${jdbc.artifactId}</artifactId>              <version>${jdbc.version}</version>            </dependency>          </dependencies>        </plugin>      </plugins>    </build>  ...  </project>
  否则就用 ture ,它可以帮你搞定一切。下面就让我们来运行 “mvn appfuse:gen” 生成代码。)

7、接下來把生成的源代碼寫到源程序中。使用mvn appfuse:install

8、執行mvn jetty:run-war, 即可運行建好生成的項目


中文乱码问题

近来学习appfuse2一直受着displaytag中文乱码的困挠,如果是刚刚下载下来的源代码编译后没有乱码,但是如果做了相应的displaytag中文修改、或者增加了新pojo之后,重新启动就会产生乱码。
百度、google了几天,发现都是appfuse1的解决办法,appfuse2的几乎没有,有的只是从生成的war档文件中修改,但是如果重新修改添加displaytag之后就又有问题了,没有冲根本上解决……

这个过程中,发现ApplicationResources_zh.properties却无论如何都没有乱码。后来仔细检查pom.xml配置文件,发现ApplicationResources_zh.properties和displaytag_zh.properties对配置还真不一样,原文件对ApplicationResources.properties的相关配置文件是:

<plugin> 
<groupId>org.codehaus.mojo</groupId> 
<artifactId>native2ascii-maven-plugin</artifactId> 
<version>1.0-alpha-1</version> 
<configuration> 
<dest>target/classes</dest> 
<src>src/main/resources</src> 
</configuration> 
<executions> 
<execution> 
<id>native2ascii-utf8</id> 
<goals> 
<goal>native2ascii</goal> 
</goals> 
<configuration> 
<encoding>UTF8</encoding> 
<includes> 
ApplicationResources_ko.properties, 
ApplicationResources_no.properties, 
ApplicationResources_tr.properties, 
ApplicationResources_zh*.properties 
</includes> 
</configuration> 
</execution> 
<execution> 
<id>native2ascii-8859_1</id> 
<goals> 
<goal>native2ascii</goal> 
</goals> 
<configuration> 
<encoding>8859_1</encoding> 
<includes> 
ApplicationResources_de.properties, 
ApplicationResources_fr.properties, 
ApplicationResources_nl.properties, 
ApplicationResources_pt*.properties 
ApplicationResources_zh*.properties 
</includes> 
</configuration> 
</execution> 
</executions> 
</plugin> 

以及——

<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>ApplicationResources_de.properties</exclude>
<exclude>ApplicationResources_fr.properties</exclude>
<exclude>ApplicationResources_ko.properties</exclude>
<exclude>ApplicationResources_nl.properties</exclude>
<exclude>ApplicationResources_no.properties</exclude>
<exclude>ApplicationResources_pt*.properties</exclude>
<exclude>ApplicationResources_tr.properties</exclude>
<exclude>ApplicationResources_zh*.properties</exclude>
<exclude>applicationContext-resources.xml</exclude>
<exclude>struts.xml</exclude>
</excludes>
<filtering>true</filtering>
</resource>

发现一直都没有对关于ApplicationResources以外的*.properties文件进行配置处理,于是照以上看来native2ascii只有对ApplicationResources进行了国际化编码了而已,其他的都没有进行。于是做了一下修改——

<plugin> 
<groupId>org.codehaus.mojo</groupId> 
<artifactId>native2ascii-maven-plugin</artifactId> 
<version>1.0-alpha-1</version> 
<configuration> 
<dest>target/classes</dest> 
<src>src/main/resources</src> 
</configuration> 
<executions> 
<execution> 
<id>native2ascii-utf8</id> 
<goals> 
<goal>native2ascii</goal> 
</goals> 
<configuration> 
<encoding>[color=red]UTF-8[/color]</encoding> 
<includes> 
ApplicationResources_ko.properties, 
ApplicationResources_no.properties, 
ApplicationResources_tr.properties, 
[color=red]*_zh*.properties[/color] 
</includes> 
</configuration> 
</execution> 
<execution> 
<id>native2ascii-8859_1</id> 
<goals> 
<goal>native2ascii</goal> 
</goals> 
<configuration> 
<encoding>8859_1</encoding> 
<includes> 
ApplicationResources_de.properties, 
ApplicationResources_fr.properties, 
ApplicationResources_nl.properties, 
ApplicationResources_pt*.properties 
</includes> 
</configuration> 
</execution> 
</executions> 
</plugin> 

以及——

<resource> 
<directory>src/main/resources</directory> 
<excludes> 
<exclude>ApplicationResources_de.properties</exclude> 
<exclude>ApplicationResources_fr.properties</exclude> 
<exclude>ApplicationResources_ko.properties</exclude> 
<exclude>ApplicationResources_nl.properties</exclude> 
<exclude>ApplicationResources_no.properties</exclude> 
<exclude>ApplicationResources_pt*.properties</exclude> 
<exclude>ApplicationResources_tr.properties</exclude> 
<exclude>[color=red]*_zh*.properties[/color]</exclude> 
<exclude>applicationContext-resources.xml</exclude> 
<exclude>struts.xml</exclude> 
</excludes> 
<filtering>true</filtering> 
</resource> 

注意以上做了红字部分的修改

最后重启项目,登录测试,发现一切Ok,后来不管在displaytag对显示属性中作任何修改,乱码都不会出现,看来是彻底解决了。
[/size]
分享到:
评论

相关推荐

    mypro.rar_Acegi Appfuse2 _acegi_java 数据库_java 权限_数据权限控制

    Spring+acegi+ext2.0+mysql 开发 acegi做权限控制 ext2.0做前台显示 spring 做控制层 mysql 做数据库

    appfuse_quick_start

    AppFuse项目的主要目的是帮助你加速web应用程序的开发。

    Appfuse教程Appfuse开发.pdf

     通过关注AppFuse,我们可以看到目前国外的主流开发都使用了哪些技术,开发方式是什么样的,可能达到什么样的结果,而在以前,是很少能够看到这样完整的例子的。  AppFuse的另一个启示是:我们可以依靠开源软件的...

    appfuse

    使用appfuse2.0,下载过来的实例源码,没有jar包

    Appfuse2搭建文档

    个人在应用Appfuse2开发时写的图文搭建文档,数据库是Oracle

    AppFuse

    本文以一个 J2EE 开发者的角度,借助一个简单的应用示例,在融合了个人经验的基础上介绍了如何用 ...通过阅读本文,读者不仅能够学会用 AppFuse 进行开发,而且能够充分体会到 AppFuse 提供的“快速开发”的优越性。

    Appfuse开发教程

    Appfuse开发教程

    appfuse开发文档

    appfuse缩减开发时间,为程序员缩减大约85%的开发时间。本教程将带你进入appfuse的开发工作

    SSH学习及开发框架-appfuse

    appfuse 有struts2+hibernate+spring的整合 springmvc+hibernate+spring的整合 多模块,但模块都有 学习开发参考使用非常方便 可以到官方下载最新版的,我只是把自己下载的打包整理一下 注意哈,都是基于maven的...

    appfuse-light-webwork-spring-jdbc-1.8.2.zip_Java 8_appfuse_webwo

    appfuse对java web开发很有帮助,里边用了分层的思想进行开发的

    可直接使用的appfuse项目

    AppFuse是一个集成了众多当前最流行开源框架与工具(包括Hibernate、ibatis、Struts、Spring、DBUnit、Maven、Log4J、Struts Menu、Xdoclet、SiteMesh、OSCache、JUnit、JSTL等(现在还有lucene的,无敌了))于一身的...

    appfuse2学习日记

    自己学习appfuse2的相关日志,里面包含了一些在网上已经文档的综合.

    APPFUSE工具研究.doc

    Appfuse是一个开源的工程应用,它集成了现在最流行的开发框架到该应用中,使用Maven可以很方便的开发和部署因为。也可以集成到现在流行的开源开发工具如eclipse,idea等。现在让我们简单的看看APPFUSE开发应用的简单...

    Appfuse 2.doc

    Appfuse2的一个文档,包括了一些常用命令

    建立项目原型骨架的步骤(最新版本appfuse)appfuse2.1.0-M2

    建立项目原型骨架的步骤(最新版本appfuse)appfuse2.1.0-M2 spring3.0 hibernte3.3 struts2.1.8

    appfuse 使用手册

    详细描述了APPFUSE的开发流程,带你进入APPFUSE的框架

    AppFuse入门文档(AppFuse与SpringMVC+mybatis整合)

    本文档详细描述了AppFuse与SpringMVC+mybatis整合的过程,只要你懂一些基本的eclipse操作和基本的maven命令,就可以在三分钟之内迅速的搭建出一个AppFuse的架构

    使用appfuse2建立项目原型骨架的步骤

    使用appfuse2建立项目原型骨架的步骤 appfuse2 项目原型 骨架

Global site tag (gtag.js) - Google Analytics