The <extjsGenerator> element is used to define properties of the Java model generator. The Java Model Generator builds primary key classes, record classes, and Query by Example classes that match the introspected table. This element is a required child element of the <context> element.
属性 | 描述 |
---|---|
appName | 应用名称, 不可为空,示例如 ESSM 等 . |
targetPackage | 短包名,如 crm, 如 test 等 . |
targetProject | 目标文件目录,相对路径;(原来的生成器不会创建,此修改版本会进行创建). |
下面的表格列出了所有可用的 <property> 子元素:
属性名 | 属性值 |
---|---|
constructorBased |
This property is used to select whether MyBatis Generator will generate a constructor
for the class that accepts a value for each field in the class. Also, the SQL result map
will be built to use the constructor rather than the "setter" for each field.
This property is only applicable for MyBatis3 and will be ignored for iBATIS2. This property is ignored (and forced "true") if the "immutable" property is set "true". This property can be overridden by the corresponding property in a <table> element. 默认值是 false |
enableSubPackages | This property is used to select whether MyBatis Generator will generate different
Java packages for the objects based on the catalog and schema of the
introspected table.
For example, suppose a table MYTABLE in schema MYSCHMA. Also suppose that the targetPackage attribute is set to "com.mycompany". If this property is true, the generated objects for the table will be placed in the package "com.mycompany.myschema". If the property is false, the generated objects will be placed in the "com.mycompany" schema. 默认值是 false |
immutable |
This property is used to select whether MyBatis Generator will generate immutable
model classes - this means that the classes will not have "setter" methods and
the constructor will accept values for each field in the class.
If true, this forces the model classes to be built with paramterized constructors regardless of the value of the "constructorBased" property. This property is only applicable for MyBatis3 and will be ignored for iBATIS2. This property can be overridden by the corresponding property in a <table> element. 默认值是 false |
rootClass | This property can be used to specify a root class for all generated
Java model objects. MyBatis Generator will specify this value as the super class
of the primary key object, if the table has a primary key, or the
record object otherwise. This value may be overridden by specifying
the rootClass property on a Table configuration.
重要: If MyBatis Generator is able to load the root class, then it will not override a property in the root class that exactly matches a property that would normally be generated. An exact match of a property is defined as follows
If specified, the value of this property should be a fully qualified class name (like com.mycompany.MyRootClass). |
trimStrings |
This property is used to select whether MyBatis Generator adds code to trim
the white space from character fields returned from the database.
This can be useful if your database stores data in CHAR fields rather than
VARCHAR fields. When true, MyBatis Generator will insert code to trim character fields.
默认值是 false |
appName为 "ESSM"; 短包名为 "test"; 生成的Extjs模板的包名类似于"ESSM.xxx.test.Xxx" 等. 文件位于 "\MBGTestProject\src\main\webapp\static\app\xxx\test\" 之类的目录下。
<extjsGenerator appName="ESSM" targetPackage="test" targetProject="\MBGTestProject\src\main\webapp\static\app"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </extjsGenerator>