appfuse分析
1、.\properties\appfuse\generator.properties分析
# @(#)generator.properties
### appliction settings ###
#框架名称,在运行com.codegenerator.runner.appfusegenerator时,作为args[]的参数被传入。此名称决定了配置文件及模板文件
的存放路径。如框架名为appfuse,则相关的文件夹为:properties\appfuse、templates\appfuse
framework=appfuse
appname=appfuse_joa
### if custom managers are not required uncomment the exclude parameter
### 用于配置哪些代码包不需要生成
#exclude=manager,dao,hibernate.xml.beansvm,service
### if only the tbl class is required uncomment the include parameter
# 用于配置需要生成的代码包
#include=tbl
### single key generator class and types are as below
singlekeygenerator=increment:long,integer,short
### default package prefix and default package location
## 配置默认的包前缀及包的位置信息
packagelocation=com/zytech
packageprefix=com.zytech
templatelocation=.\\templates
### anything that matches keys in filelocations goes into this directory
## 代码输出目录
javaoutputlocation=d:\\temp\\appfuse_joa\\
### otherwise if no match default output directory is here
defaultoutputlocation=..\\generated\\
### these three resolver properties files customize the output file locations
### package names and field types
filelocationresolver=filelocations
filenameresolver=filenames
packagenameresolver=packagenames
#fieldtyperesolver=fieldtypes
### controller settings [pick one of strutsspringwebworktapestryjsf] ###
## 设定需要生成哪个mvc的代码,及代码模板
# [all] - common templates required for all mvc frameworks
velocitylistcommon=commontemplates
# [struts]
#velocityliststruts=strutstemplates
# [string]
#velocitylistspring=springtemplates
# [webwork]
velocitylistwebwork=webworktemplates
# [jsf]
#velocitylistjsf=jsftemplates
# [tapestry]
#velocitylisttapestry=tapestrytemplates
### database settings ###
# 数据库配置
# [all databases]
dbuserid=zyoa
dbpasswd=zyoa
dbschema=zyoa
# [db2]
#jdbcdriver=com.ibm.db2.jdbc.app.db2driver
#dburl=jdbc:db2:d2spdvt
# [oracle]
#jdbcdriver=oracle.jdbc.driver.oracledriver
#dburl=jdbc:oracle:thin:@192.168.1.199:1521:orcl
# [mysql]
jdbcdriver=com.mysql.jdbc.driver
dburl=jdbc:mysql://localhost:3306/zyoa
# [hsql]
#jdbcdriver=org.hsqldb.jdbcdriver
#dburl=jdbc:hsqldb:file:d:\\hsqldb\\data\\testdb
# [postgresql]
#jdbcdriver=org.postgresql.driver
#dburl=jdbc:postgresql://localhost/mydatabase
### mail settings ###
# 代码中的author备注信息
mailid=jhxck@hotmail.com
mailname=xiangchunke
#mailid=nanderson@sum-ware.com
#mailname=nathan anderson
2、oracle下速度特别慢的原因:
在生成getprimarykeys()时特别慢,不知怎么回事
后经考证:是oracle的问题,家里不正常,公司正常
3、中文问题
在vm中使用了中文,生成的代码却是乱码。
解决办法:修改velocity的编码。但是.properties文件中的中文却还没办法
private void initvelocity(string templatedirectory) throws exception {
// init velocity
properties p = new properties();
// 设置模板路径
p.put("file.resource.loader.path",templatedirectory);
//设置velocity的输入输出编码转换
p.setproperty("output.encoding", "gb2312");
p.setproperty("input.encoding", "iso-8859-1");//输入的编码
vengine = new velocityengine();
vengine.init( p );
}
4、现在所剩问题:
在生成xml文件时,将文件内容追加进去。而不是文件存在就不再生成
5、各properties配置文件内容说明
commontemplates.properties: 基本代码的vm模板名称配置,对应于templates\appfuse\common
filelocations.properties: 各种生成的代码文件的输出路径
filenames.properties: 暂时不知用途
generator.properties: 整个系统的配置。主要是包、输出位置、数据库联接信息
packagenames.properties: 各个数据库表生成的代码所属的包名
jsffilelocations.properties jsftemplates.properties :jsf系统的配置信息
springtemplates.properties strutstemplates.properties tapestrytemplates.properties
tapestryfilelocations.properties: 各种mvc框架的配置文件
6、templates文件夹下的文件
为velocity模板文件。改变生成的代码,主要是修改这些文件
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器