Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mybatis-generator-plugin
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mybatis-generator-plugin
Commits
e0614069
Commit
e0614069
authored
May 28, 2018
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TableConfigurationPlugin 测试用例
parent
caa5144d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
262 additions
and
19 deletions
+262
-19
src/main/java/com/itfsw/mybatis/generator/plugins/TableConfigurationPlugin.java
...w/mybatis/generator/plugins/TableConfigurationPlugin.java
+67
-14
src/test/java/com/itfsw/mybatis/generator/plugins/TableConfigurationPluginTest.java
...batis/generator/plugins/TableConfigurationPluginTest.java
+82
-5
src/test/resources/scripts/TableConfigurationPlugin/mybatis-generator-with-columnRenamingRule.xml
...ationPlugin/mybatis-generator-with-columnRenamingRule.xml
+57
-0
src/test/resources/scripts/TableConfigurationPlugin/mybatis-generator-with-domainObjectRenamingRule.xml
...lugin/mybatis-generator-with-domainObjectRenamingRule.xml
+56
-0
No files found.
src/main/java/com/itfsw/mybatis/generator/plugins/TableConfigurationPlugin.java
View file @
e0614069
...
...
@@ -20,14 +20,22 @@ import com.itfsw.mybatis.generator.plugins.utils.BasePlugin;
import
com.itfsw.mybatis.generator.plugins.utils.BeanUtils
;
import
com.itfsw.mybatis.generator.plugins.utils.hook.ITableConfigurationHook
;
import
org.mybatis.generator.api.FullyQualifiedTable
;
import
org.mybatis.generator.api.IntrospectedColumn
;
import
org.mybatis.generator.api.IntrospectedTable
;
import
org.mybatis.generator.config.ColumnRenamingRule
;
import
org.mybatis.generator.config.DomainObjectRenamingRule
;
import
org.mybatis.generator.config.PropertyRegistry
;
import
org.mybatis.generator.config.TableConfiguration
;
import
org.mybatis.generator.internal.util.StringUtility
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
static
org
.
mybatis
.
generator
.
internal
.
util
.
JavaBeansUtil
.
getCamelCaseString
;
import
static
org
.
mybatis
.
generator
.
internal
.
util
.
JavaBeansUtil
.
getValidPropertyName
;
import
static
org
.
mybatis
.
generator
.
internal
.
util
.
StringUtility
.
isTrue
;
import
static
org
.
mybatis
.
generator
.
internal
.
util
.
StringUtility
.
stringHasValue
;
/**
...
...
@@ -41,8 +49,10 @@ import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
public
class
TableConfigurationPlugin
extends
BasePlugin
implements
ITableConfigurationHook
{
public
static
final
String
PRO_TABLE_SEARCH_STRING
=
"domainObjectRenamingRule.searchString"
;
// 查找 property
public
static
final
String
PRO_TABLE_REPLACE_STRING
=
"domainObjectRenamingRule.replaceString"
;
// 替换 property
public
static
final
String
PRO_TABLE_REPLACE_DISABLE
=
"domainObjectRenamingRule.disable"
;
// 替换 property
public
static
final
String
PRO_COLUMN_SEARCH_STRING
=
"columnRenamingRule.searchString"
;
// 查找 property
public
static
final
String
PRO_COLUMN_REPLACE_STRING
=
"columnRenamingRule.replaceString"
;
// 替换 property
public
static
final
String
PRO_COLUMN_REPLACE_DISABLE
=
"columnRenamingRule.disable"
;
// 替换 property
public
static
final
String
PRO_CLIENT_SUFFIX
=
"clientSuffix"
;
// client 结尾
public
static
final
String
PRO_SQL_MAP_SUFFIX
=
"sqlMapSuffix"
;
// sqlMap 结尾
...
...
@@ -51,8 +61,11 @@ public class TableConfigurationPlugin extends BasePlugin implements ITableConfig
private
String
tableSearchString
;
private
String
tableReplaceString
;
private
boolean
tableReplaceDisable
;
private
String
columnSearchString
;
private
String
columnReplaceString
;
private
boolean
columnReplaceDisable
;
private
String
clientSuffix
;
// client 结尾
private
String
sqlMapSuffix
;
// sqlMap 结尾
...
...
@@ -67,19 +80,12 @@ public class TableConfigurationPlugin extends BasePlugin implements ITableConfig
@Override
public
boolean
validate
(
List
<
String
>
warnings
)
{
Properties
properties
=
this
.
getProperties
();
// 如果配置了searchString 或者 replaceString,二者不允许单独存在
if
((
properties
.
getProperty
(
PRO_TABLE_SEARCH_STRING
)
==
null
&&
properties
.
getProperty
(
PRO_TABLE_REPLACE_STRING
)
!=
null
)
||
(
properties
.
getProperty
(
PRO_TABLE_SEARCH_STRING
)
!=
null
&&
properties
.
getProperty
(
PRO_TABLE_REPLACE_STRING
)
==
null
)
||
(
properties
.
getProperty
(
PRO_COLUMN_SEARCH_STRING
)
==
null
&&
properties
.
getProperty
(
PRO_COLUMN_REPLACE_STRING
)
!=
null
)
||
(
properties
.
getProperty
(
PRO_COLUMN_SEARCH_STRING
)
!=
null
&&
properties
.
getProperty
(
PRO_COLUMN_REPLACE_STRING
)
==
null
))
{
warnings
.
add
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件的searchString、replaceString属性需配合使用,不能单独存在!"
);
return
false
;
}
this
.
tableSearchString
=
properties
.
getProperty
(
PRO_TABLE_SEARCH_STRING
);
this
.
tableReplaceString
=
properties
.
getProperty
(
PRO_TABLE_REPLACE_STRING
);
this
.
columnSearchString
=
properties
.
getProperty
(
PRO_COLUMN_SEARCH_STRING
);
this
.
columnReplaceString
=
properties
.
getProperty
(
PRO_COLUMN_REPLACE_STRING
);
this
.
columnReplaceString
=
properties
.
getProperty
(
PRO_COLUMN_REPLACE_STRING
);
// 和官方行为保持一致
this
.
exampleSuffix
=
properties
.
getProperty
(
PRO_EXAMPLE_SUFFIX
);
this
.
clientSuffix
=
properties
.
getProperty
(
PRO_CLIENT_SUFFIX
);
this
.
sqlMapSuffix
=
properties
.
getProperty
(
PRO_SQL_MAP_SUFFIX
);
...
...
@@ -98,24 +104,38 @@ public class TableConfigurationPlugin extends BasePlugin implements ITableConfig
TableConfiguration
tableConfiguration
=
introspectedTable
.
getTableConfiguration
();
FullyQualifiedTable
fullyQualifiedTable
=
introspectedTable
.
getFullyQualifiedTable
();
String
tableReplaceDisable
=
tableConfiguration
.
getProperty
(
PRO_TABLE_REPLACE_DISABLE
);
this
.
tableReplaceDisable
=
tableReplaceDisable
==
null
?
false
:
StringUtility
.
isTrue
(
tableReplaceDisable
);
String
columnReplaceDisable
=
tableConfiguration
.
getProperty
(
PRO_COLUMN_REPLACE_DISABLE
);
this
.
columnReplaceDisable
=
columnReplaceDisable
==
null
?
false
:
StringUtility
.
isTrue
(
columnReplaceDisable
);
String
javaClientInterfacePackage
=
(
String
)
BeanUtils
.
invoke
(
introspectedTable
,
IntrospectedTable
.
class
,
"calculateJavaClientInterfacePackage"
);
String
sqlMapPackage
=
(
String
)
BeanUtils
.
invoke
(
introspectedTable
,
IntrospectedTable
.
class
,
"calculateSqlMapPackage"
);
String
javaModelPackage
=
(
String
)
BeanUtils
.
invoke
(
introspectedTable
,
IntrospectedTable
.
class
,
"calculateJavaModelPackage"
);
// --------------------- table 重命名 ----------------------------
if
(
tableConfiguration
.
getDomainObjectRenamingRule
()
==
null
&&
this
.
tableSearchString
!=
null
&&
this
.
tableReplaceString
!=
null
)
{
&&
this
.
tableSearchString
!=
null
&&
!
this
.
tableReplaceDisable
)
{
DomainObjectRenamingRule
rule
=
new
DomainObjectRenamingRule
();
rule
.
setSearchString
(
this
.
tableSearchString
);
rule
.
setReplaceString
(
this
.
tableReplaceString
);
tableConfiguration
.
setDomainObjectRenamingRule
(
rule
);
BeanUtils
.
setProperty
(
introspectedTable
.
getFullyQualifiedTable
(),
"domainObjectRenamingRule"
,
rule
);
// 重新初始化一下属性
BeanUtils
.
invoke
(
introspectedTable
,
IntrospectedTable
.
class
,
"calculateJavaClientAttributes"
);
BeanUtils
.
invoke
(
introspectedTable
,
IntrospectedTable
.
class
,
"calculateModelAttributes"
);
BeanUtils
.
invoke
(
introspectedTable
,
IntrospectedTable
.
class
,
"calculateXmlAttributes"
);
}
// --------------------- column 重命名 ---------------------------
if
(
tableConfiguration
.
getColumnRenamingRule
()
==
null
&&
this
.
columnSearchString
!=
null
&&
this
.
columnReplaceString
!=
null
)
{
&&
this
.
columnSearchString
!=
null
&&
!
this
.
columnReplaceDisable
)
{
ColumnRenamingRule
rule
=
new
ColumnRenamingRule
();
rule
.
setSearchString
(
this
.
columnSearchString
);
rule
.
setReplaceString
(
this
.
columnReplaceString
);
tableConfiguration
.
setColumnRenamingRule
(
rule
);
// introspectedTable 使用到的所有column过滤并替换
this
.
renameColumns
(
introspectedTable
.
getAllColumns
(),
rule
,
tableConfiguration
);
}
// ---------------------- 后缀修正 -------------------------------
...
...
@@ -159,8 +179,7 @@ public class TableConfigurationPlugin extends BasePlugin implements ITableConfig
introspectedTable
.
setMyBatis3XmlMapperFileName
(
sb
.
toString
());
}
// 2. example
// 3. example
if
(
this
.
exampleSuffix
!=
null
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
javaModelPackage
);
...
...
@@ -169,7 +188,7 @@ public class TableConfigurationPlugin extends BasePlugin implements ITableConfig
sb
.
append
(
this
.
exampleSuffix
);
introspectedTable
.
setExampleType
(
sb
.
toString
());
}
//
3
. model
//
4
. model
if
(
this
.
modelSuffix
!=
null
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
javaModelPackage
);
...
...
@@ -198,4 +217,38 @@ public class TableConfigurationPlugin extends BasePlugin implements ITableConfig
e
.
printStackTrace
();
}
}
/**
* column rename
* @param columns
* @param rule
* @param tc
*/
private
void
renameColumns
(
List
<
IntrospectedColumn
>
columns
,
ColumnRenamingRule
rule
,
TableConfiguration
tc
)
{
Pattern
pattern
=
Pattern
.
compile
(
rule
.
getSearchString
());
String
replaceString
=
rule
.
getReplaceString
();
replaceString
=
replaceString
==
null
?
""
:
replaceString
;
for
(
IntrospectedColumn
introspectedColumn
:
columns
)
{
String
calculatedColumnName
;
if
(
pattern
==
null
)
{
calculatedColumnName
=
introspectedColumn
.
getActualColumnName
();
}
else
{
Matcher
matcher
=
pattern
.
matcher
(
introspectedColumn
.
getActualColumnName
());
calculatedColumnName
=
matcher
.
replaceAll
(
replaceString
);
}
if
(
isTrue
(
tc
.
getProperty
(
PropertyRegistry
.
TABLE_USE_ACTUAL_COLUMN_NAMES
)))
{
introspectedColumn
.
setJavaProperty
(
getValidPropertyName
(
calculatedColumnName
));
}
else
if
(
isTrue
(
tc
.
getProperty
(
PropertyRegistry
.
TABLE_USE_COMPOUND_PROPERTY_NAMES
)))
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
calculatedColumnName
);
sb
.
append
(
'_'
);
sb
.
append
(
getCamelCaseString
(
introspectedColumn
.
getRemarks
(),
true
));
introspectedColumn
.
setJavaProperty
(
getValidPropertyName
(
sb
.
toString
()));
}
else
{
introspectedColumn
.
setJavaProperty
(
getCamelCaseString
(
calculatedColumnName
,
false
));
}
}
}
}
src/test/java/com/itfsw/mybatis/generator/plugins/TableConfigurationPluginTest.java
View file @
e0614069
...
...
@@ -16,12 +16,17 @@
package
com
.
itfsw
.
mybatis
.
generator
.
plugins
;
import
com.itfsw.mybatis.generator.plugins.tools.AbstractShellCallback
;
import
com.itfsw.mybatis.generator.plugins.tools.DBHelper
;
import
com.itfsw.mybatis.generator.plugins.tools.MyBatisGeneratorTool
;
import
com.itfsw.mybatis.generator.plugins.tools.*
;
import
org.apache.ibatis.session.SqlSession
;
import
org.junit.Assert
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.mybatis.generator.api.GeneratedJavaFile
;
import
org.mybatis.generator.api.MyBatisGenerator
;
import
org.mybatis.generator.api.dom.java.Field
;
import
org.mybatis.generator.api.dom.java.TopLevelClass
;
import
java.util.List
;
/**
* ---------------------------------------------------------------------------
...
...
@@ -37,13 +42,85 @@ public class TableConfigurationPluginTest {
DBHelper
.
createDB
(
"scripts/TableConfigurationPlugin/init.sql"
);
}
/**
* 测试domainObjectRenamingRule
*/
@Test
public
void
test
()
throws
Exception
{
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/TableConfigurationPlugin/mybatis-generator.xml"
);
public
void
testDomainObjectRenamingRule
()
throws
Exception
{
// 规则 ^T 替换成 Test
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/TableConfigurationPlugin/mybatis-generator-with-domainObjectRenamingRule.xml"
);
MyBatisGenerator
myBatisGenerator
=
tool
.
generate
();
for
(
GeneratedJavaFile
file
:
myBatisGenerator
.
getGeneratedJavaFiles
()){
String
name
=
file
.
getCompilationUnit
().
getType
().
getShortName
();
Assert
.
assertTrue
(
name
.
matches
(
"Testb.*"
));
}
// 执行一条语句确认其可用
tool
.
generate
(()
->
DBHelper
.
resetDB
(
"scripts/TableConfigurationPlugin/init.sql"
),
new
AbstractShellCallback
()
{
@Override
public
void
reloadProject
(
SqlSession
sqlSession
,
ClassLoader
loader
,
String
packagz
)
throws
Exception
{
ObjectUtil
tbMapper
=
new
ObjectUtil
(
sqlSession
.
getMapper
(
loader
.
loadClass
(
packagz
+
".TestbMapper"
)));
ObjectUtil
tbExample
=
new
ObjectUtil
(
loader
,
packagz
+
".TestbExample"
);
ObjectUtil
criteria
=
new
ObjectUtil
(
tbExample
.
invoke
(
"createCriteria"
));
criteria
.
invoke
(
"andIdLessThan"
,
4L
);
// sql
String
sql
=
SqlHelper
.
getFormatMapperSql
(
tbMapper
.
getObject
(),
"selectByExample"
,
tbExample
.
getObject
());
Assert
.
assertEquals
(
sql
,
"select id, field1, inc_f1, inc_f2, inc_f3 from tb WHERE ( id < '4' )"
);
// 执行
List
list
=
(
List
)
tbMapper
.
invoke
(
"selectByExample"
,
tbExample
.
getObject
());
Assert
.
assertEquals
(
list
.
size
(),
3
);
}
});
}
/**
* 测试columnRenamingRule
*/
@Test
public
void
testColumnRenamingRule
()
throws
Exception
{
// 规则 ^T 替换成 Test
MyBatisGeneratorTool
tool
=
MyBatisGeneratorTool
.
create
(
"scripts/TableConfigurationPlugin/mybatis-generator-with-columnRenamingRule.xml"
);
MyBatisGenerator
myBatisGenerator
=
tool
.
generate
();
for
(
GeneratedJavaFile
file
:
myBatisGenerator
.
getGeneratedJavaFiles
()){
if
(
file
.
getFileName
().
equals
(
"Tb.java"
)){
int
count
=
0
;
for
(
Field
field
:
((
TopLevelClass
)(
file
.
getCompilationUnit
())).
getFields
()){
if
(
field
.
getName
().
startsWith
(
"increment"
)){
count
++;
}
}
Assert
.
assertEquals
(
count
,
3
);
}
}
// 执行一条语句确认其可用
tool
.
generate
(()
->
DBHelper
.
resetDB
(
"scripts/TableConfigurationPlugin/init.sql"
),
new
AbstractShellCallback
()
{
@Override
public
void
reloadProject
(
SqlSession
sqlSession
,
ClassLoader
loader
,
String
packagz
)
throws
Exception
{
ObjectUtil
tbMapper
=
new
ObjectUtil
(
sqlSession
.
getMapper
(
loader
.
loadClass
(
packagz
+
".TbMapper"
)));
ObjectUtil
tbExample
=
new
ObjectUtil
(
loader
,
packagz
+
".TbExample"
);
ObjectUtil
criteria
=
new
ObjectUtil
(
tbExample
.
invoke
(
"createCriteria"
));
criteria
.
invoke
(
"andIdEqualTo"
,
4L
);
ObjectUtil
tb
=
new
ObjectUtil
(
loader
,
packagz
+
".Tb"
);
tb
.
set
(
"id"
,
4L
);
tb
.
set
(
"field1"
,
"ts1"
);
tb
.
set
(
"incrementF1"
,
5L
);
// sql
String
sql
=
SqlHelper
.
getFormatMapperSql
(
tbMapper
.
getObject
(),
"updateByExample"
,
tb
.
getObject
(),
tbExample
.
getObject
());
Assert
.
assertEquals
(
sql
,
"update tb set id = 4, field1 = 'ts1', inc_f1 = 5, inc_f2 = null, inc_f3 = null WHERE ( id = '4' )"
);
// 执行
int
count
=
(
int
)
tbMapper
.
invoke
(
"updateByExample"
,
tb
.
getObject
(),
tbExample
.
getObject
());
Assert
.
assertEquals
(
count
,
1
);
// 执行结果查询
List
list
=
(
List
)
tbMapper
.
invoke
(
"selectByExample"
,
tbExample
.
getObject
());
ObjectUtil
result
=
new
ObjectUtil
(
list
.
get
(
0
));
Assert
.
assertEquals
(
result
.
get
(
"id"
),
4L
);
Assert
.
assertEquals
(
result
.
get
(
"field1"
),
"ts1"
);
Assert
.
assertEquals
(
result
.
get
(
"incrementF1"
),
5L
);
}
});
}
...
...
src/test/resources/scripts/TableConfigurationPlugin/mybatis-generator-with-columnRenamingRule.xml
0 → 100644
View file @
e0614069
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2018.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<properties
resource=
"db.properties"
/>
<!--导入属性配置 -->
<context
id=
"default"
targetRuntime=
"MyBatis3"
>
<!-- 插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.TableConfigurationPlugin"
>
<property
name=
"columnRenamingRule.searchString"
value=
"^inc"
/>
<property
name=
"columnRenamingRule.replaceString"
value=
"Increment"
/>
</plugin>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass=
"${driver}"
connectionURL=
"${url}"
userId=
"${username}"
password=
"${password}"
/>
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator
targetPackage=
""
targetProject=
""
>
<!-- 是否对model添加 构造函数 -->
<property
name=
"constructorBased"
value=
"true"
/>
<!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator
targetPackage=
""
targetProject=
""
/>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
""
targetProject=
""
type=
"XMLMAPPER"
/>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 要自动生成的表 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<table
tableName=
"tb"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
<table
tableName=
"tb_keys"
/>
</context>
</generatorConfiguration>
\ No newline at end of file
src/test/resources/scripts/TableConfigurationPlugin/mybatis-generator-with-domainObjectRenamingRule.xml
0 → 100644
View file @
e0614069
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2018.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<properties
resource=
"db.properties"
/>
<!--导入属性配置 -->
<context
id=
"default"
targetRuntime=
"MyBatis3"
>
<!-- 插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.TableConfigurationPlugin"
>
<property
name=
"domainObjectRenamingRule.searchString"
value=
"^T"
/>
<property
name=
"domainObjectRenamingRule.replaceString"
value=
"Test"
/>
</plugin>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass=
"${driver}"
connectionURL=
"${url}"
userId=
"${username}"
password=
"${password}"
/>
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator
targetPackage=
""
targetProject=
""
>
<!-- 是否对model添加 构造函数 -->
<property
name=
"constructorBased"
value=
"true"
/>
<!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator
targetPackage=
""
targetProject=
""
/>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
""
targetProject=
""
type=
"XMLMAPPER"
/>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 要自动生成的表 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<table
tableName=
"tb"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment