读书人

AppFuse生成模块方法:(从实体类生成)

发布时间: 2013-04-20 19:43:01 作者: rapoo

AppFuse生成模块步骤:(从实体类生成)

<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}o\:* {behavior:url(#default#VML);}w\:* {behavior:url(#default#VML);}.shape {behavior:url(#default#VML);}</style><![endif]-->

<!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument></xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles></xml><![endif]--><!--[if gte mso 10]><style> /* Style Definitions */ table.MsoNormalTable{mso-style-name:普通表格;mso-tstyle-rowband-size:0;mso-tstyle-colband-size:0;mso-style-noshow:yes;mso-style-parent:"";mso-padding-alt:0cm 5.4pt 0cm 5.4pt;mso-para-margin:0cm;mso-para-margin-bottom:.0001pt;mso-pagination:widow-orphan;font-size:10.0pt;font-family:"Times New Roman";mso-ansi-language:#0400;mso-fareast-language:#0400;mso-bidi-language:#0400;}</style><![endif]-->

AppFuse生成模块步骤:(从实体类生成)

1.???????? 在dao目录下新建模块(自己的模块名称(包))

AppFuse生成模块方法:(从实体类生成)

?

2.???????? 在模块下新建model 包:

AppFuse生成模块方法:(从实体类生成)

?

3.???????? 在model 包下新建实体类(即为对应的实体类)

????????? AppFuse生成模块方法:(从实体类生成)

@struts.form include-all="true" extends="BaseForm"

让 appfuse 生成一个actionForm 并且用实体类的所有属性

@hibernate.class table="TBL_PM_VERSION_GROUP"

让 appfuse 生成 数据库表为TBL_PM_VERSION_GROUP的表

?

4.???????? 在实体类中写自己的属性 (要有默认的构造函数)

实体类中必须要有让struts 验证的字段

例如

AppFuse生成模块方法:(从实体类生成)

然后生成get/set方法,并重写hashCode.toString和equals方法

在set或get方法上添加 xdoclet 代码(注释)

语法如下:

???????? 生成主键(sequence)

@hibernate.id generator-type="java.lang.Long"

??? ??? column="ID" length="12"

@hibernate.generator-paramname="sequence" value="GROUP_VERSION_SEQ"

generator-class 指定让怎么生成主键(oracle :sequence;sqlserver:identity….针对整形数字)

type 指定数据类型,

column 指定数据字段名称

length 指定长度

generator-param 针对oracle的sequence

name 指定generator-class

value 数据库中的 sequence? (不用自己创建 ,hibernate 自动生成)

???????? 基本数据类型

@hibernate.property type="java.lang.Long" column="OBJECT_ID" length="12"

Type 指定数据库字段对应的数据类型,

Column 指定数据字段名称

Length 指定字段长度

???????? 对象类型

@hibernate.many-to-one column="COLUMN_ID"

Column 指定外键

?

例如

AppFuse生成模块方法:(从实体类生成)

指定了versionColumn这个属性 是 VersionColumn 这个实体类的外键

5.???????? 生成代码

在dos中进入工程下AppFuse生成模块方法:(从实体类生成)目录

输入ant install-detailed

?Dos 出现AppFuse生成模块方法:(从实体类生成)

选择 pojo 回车

AppFuse生成模块方法:(从实体类生成)

输入自己的实体类名称

?如:Pm

AppFuse生成模块方法:(从实体类生成)

输入自己的模块名称(一定要写对,不然很麻烦)

?

然后ant 就生成了在工程的src dao目录下以自己的模块名称的目录

模块名.dao 里面有个接口

模块名.dao.hibernate 里面是个实体类

Src service 目录下以自己的模块名称的目录

模块名.service 里面接口

模块名.service.impl 里面是实现类

Src web目录下以自己的模块名称的目录

模块名.webapp.action 实体类对应的 Action

在web目录下pages文件夹下自己的模块名下生成2个JSP文件

(在web commen目录下menu.jsp会自动生成你建的模块的连接,如果不想让访问可以去掉)

要在com.包名.dao.hibernate 的application-hibernate.xml 加上自己模块hibernate 的xml

AppFuse生成模块方法:(从实体类生成)

部署生成好的工程

在工程下dos命令

Ant deploy-root

自动部署到web容器下

?

?

?

AppFuse生成工程

Dos 命令下进入解压目录 ant new

?

工程生成完成

?

?

读书人网 >软件架构设计

热点推荐