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
26afb426
Commit
26afb426
authored
Jun 27, 2017
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
继续完善测试用例
parent
cec43949
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
277 additions
and
28 deletions
+277
-28
.gitignore
.gitignore
+1
-0
pom.xml
pom.xml
+7
-0
src/test/java/com/itfsw/mybatis/generator/plugins/BatchInsertPluginTest.java
...tfsw/mybatis/generator/plugins/BatchInsertPluginTest.java
+57
-4
src/test/java/com/itfsw/mybatis/generator/plugins/DBHelperTest.java
...ava/com/itfsw/mybatis/generator/plugins/DBHelperTest.java
+1
-1
src/test/java/com/itfsw/mybatis/generator/plugins/ExampleTargetPluginTest.java
...sw/mybatis/generator/plugins/ExampleTargetPluginTest.java
+1
-1
src/test/java/com/itfsw/mybatis/generator/plugins/tools/AbstractShellCallback.java
...ybatis/generator/plugins/tools/AbstractShellCallback.java
+4
-3
src/test/java/com/itfsw/mybatis/generator/plugins/tools/DBHelper.java
...a/com/itfsw/mybatis/generator/plugins/tools/DBHelper.java
+31
-5
src/test/java/com/itfsw/mybatis/generator/plugins/tools/Util.java
.../java/com/itfsw/mybatis/generator/plugins/tools/Util.java
+47
-0
src/test/resources/scripts/BatchInsertPlugin/init.sql
src/test/resources/scripts/BatchInsertPlugin/init.sql
+54
-2
src/test/resources/scripts/BatchInsertPlugin/mybatis-generator-with-error-driver.xml
...BatchInsertPlugin/mybatis-generator-with-error-driver.xml
+3
-3
src/test/resources/scripts/BatchInsertPlugin/mybatis-generator-without-model-column-plugin.xml
...tPlugin/mybatis-generator-without-model-column-plugin.xml
+3
-3
src/test/resources/scripts/BatchInsertPlugin/mybatis-generator.xml
...resources/scripts/BatchInsertPlugin/mybatis-generator.xml
+62
-0
src/test/resources/scripts/ExampleTargetPlugin/mybatis-generator-without-plugin.xml
.../ExampleTargetPlugin/mybatis-generator-without-plugin.xml
+3
-3
src/test/resources/scripts/ExampleTargetPlugin/mybatis-generator.xml
...sources/scripts/ExampleTargetPlugin/mybatis-generator.xml
+3
-3
No files found.
.gitignore
View file @
26afb426
...
...
@@ -13,3 +13,4 @@ hs_err_pid*
.idea/
mybatis-generator-plugin.iml
target/
src/main/java/com/itfsw/mybatis/generator/plugins/dao/
\ No newline at end of file
pom.xml
View file @
26afb426
...
...
@@ -53,6 +53,7 @@
<artifactId>
dom4j
</artifactId>
<version>
1.6.1
</version>
</dependency>
<!-- ############################### test ############################ -->
<!-- junit -->
<dependency>
<groupId>
junit
</groupId>
...
...
@@ -78,6 +79,12 @@
<version>
5.1.40
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.hsqldb
</groupId>
<artifactId>
hsqldb
</artifactId>
<version>
2.4.0
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++profiles++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
...
...
src/test/java/com/itfsw/mybatis/generator/plugins/BatchInsertPluginTest.java
View file @
26afb426
...
...
@@ -16,9 +16,11 @@
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.Util
;
import
org.apache.ibatis.io.Resources
;
import
org.junit.After
;
import
org.junit.After
Class
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -30,6 +32,7 @@ import org.mybatis.generator.exception.XMLParserException;
import
org.mybatis.generator.internal.DefaultShellCallback
;
import
java.io.IOException
;
import
java.lang.reflect.Method
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -83,8 +86,58 @@ public class BatchInsertPluginTest {
Assert
.
assertEquals
(
warnings
.
get
(
1
),
"itfsw:插件com.itfsw.mybatis.generator.plugins.BatchInsertPlugin插件使用前提是数据库为MySQL或者SQLserver,因为返回主键使用了JDBC的getGenereatedKeys方法获取主键!"
);
}
@After
public
void
clean
(){
helper
.
reset
();
@Test
public
void
testMethods
()
throws
IOException
,
XMLParserException
,
InvalidConfigurationException
,
SQLException
,
InterruptedException
,
ClassNotFoundException
,
NoSuchMethodException
{
List
<
String
>
warnings
=
new
ArrayList
<
String
>();
ConfigurationParser
cp
=
new
ConfigurationParser
(
warnings
);
Configuration
config
=
cp
.
parseConfiguration
(
Resources
.
getResourceAsStream
(
"scripts/BatchInsertPlugin/mybatis-generator.xml"
));
MyBatisGenerator
myBatisGenerator
=
new
MyBatisGenerator
(
config
,
new
AbstractShellCallback
(
true
)
{
@Override
public
void
reloadProject
(
ClassLoader
loader
)
{
try
{
// 1. 普通Mapper参数中List泛型为普通Model
Class
clsTbMapper
=
loader
.
loadClass
(
"com.itfsw.mybatis.generator.plugins.dao.TbMapper"
);
int
count
=
0
;
for
(
Method
method
:
clsTbMapper
.
getDeclaredMethods
()){
if
(
method
.
getName
().
equals
(
"batchInsert"
)){
Assert
.
assertEquals
(
Util
.
getListActualType
(
method
.
getGenericParameterTypes
()[
0
]),
"com.itfsw.mybatis.generator.plugins.dao.model.Tb"
);
count
++;
}
if
(
method
.
getName
().
equals
(
"batchInsertSelective"
)){
Assert
.
assertEquals
(
Util
.
getListActualType
(
method
.
getGenericParameterTypes
()[
0
]),
"com.itfsw.mybatis.generator.plugins.dao.model.Tb"
);
Assert
.
assertEquals
(
method
.
getGenericParameterTypes
()[
1
].
getTypeName
(),
"com.itfsw.mybatis.generator.plugins.dao.model.Tb$Column[]"
);
count
++;
}
}
Assert
.
assertEquals
(
count
,
2
);
// 2. 带有WithBlobs
Class
clsTbBlobsMapper
=
loader
.
loadClass
(
"com.itfsw.mybatis.generator.plugins.dao.TbBlobsMapper"
);
count
=
0
;
for
(
Method
method
:
clsTbBlobsMapper
.
getDeclaredMethods
()){
if
(
method
.
getName
().
equals
(
"batchInsert"
)){
Assert
.
assertEquals
(
Util
.
getListActualType
(
method
.
getGenericParameterTypes
()[
0
]),
"com.itfsw.mybatis.generator.plugins.dao.model.TbBlobsWithBLOBs"
);
count
++;
}
if
(
method
.
getName
().
equals
(
"batchInsertSelective"
)){
Assert
.
assertEquals
(
Util
.
getListActualType
(
method
.
getGenericParameterTypes
()[
0
]),
"com.itfsw.mybatis.generator.plugins.dao.model.TbBlobsWithBLOBs"
);
Assert
.
assertEquals
(
method
.
getGenericParameterTypes
()[
1
].
getTypeName
(),
"com.itfsw.mybatis.generator.plugins.dao.model.TbBlobsWithBLOBs$Column[]"
);
count
++;
}
}
Assert
.
assertEquals
(
count
,
2
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
Assert
.
assertTrue
(
false
);
}
}
},
warnings
);
myBatisGenerator
.
generate
(
null
,
null
,
null
,
true
);
}
@AfterClass
public
static
void
clean
(){
DBHelper
.
reset
();
}
}
src/test/java/com/itfsw/mybatis/generator/plugins/DBHelperTest.java
View file @
26afb426
...
...
@@ -59,6 +59,6 @@ public class DBHelperTest {
statement
.
close
();
connection
.
close
();
sqlSession
.
close
();
h
elper
.
reset
();
DBH
elper
.
reset
();
}
}
src/test/java/com/itfsw/mybatis/generator/plugins/ExampleTargetPluginTest.java
View file @
26afb426
...
...
@@ -92,6 +92,6 @@ public class ExampleTargetPluginTest {
@After
public
void
clean
(){
h
elper
.
reset
();
DBH
elper
.
reset
();
}
}
src/test/java/com/itfsw/mybatis/generator/plugins/tools/AbstractShellCallback.java
View file @
26afb426
...
...
@@ -16,6 +16,7 @@
package
com
.
itfsw
.
mybatis
.
generator
.
plugins
.
tools
;
import
org.junit.Assert
;
import
org.mybatis.generator.api.ShellCallback
;
import
org.mybatis.generator.exception.ShellException
;
...
...
@@ -62,8 +63,7 @@ public abstract class AbstractShellCallback implements ShellCallback {
*/
@Override
public
void
refreshProject
(
String
project
)
{
String
daoDir
=
project
+
"/com/itfsw/mybatis/generator/plugins/dao"
;
List
<
File
>
files
=
getJavaFiles
(
new
File
(
daoDir
));
List
<
File
>
files
=
getJavaFiles
(
new
File
(
project
+
"/com/itfsw/mybatis/generator/plugins/dao"
));
if
(!
files
.
isEmpty
())
{
JavaCompiler
compiler
=
ToolProvider
.
getSystemJavaCompiler
();
...
...
@@ -80,9 +80,10 @@ public abstract class AbstractShellCallback implements ShellCallback {
task
.
call
();
try
{
reloadProject
(
new
URLClassLoader
(
new
URL
[]{
new
URL
(
daoDir
)}));
reloadProject
(
new
URLClassLoader
(
new
URL
[]{
new
File
(
project
).
toURI
().
toURL
(
)}));
}
catch
(
MalformedURLException
e
)
{
e
.
printStackTrace
();
Assert
.
assertTrue
(
false
);
}
}
else
{
reloadProject
(
this
.
getClass
().
getClassLoader
());
...
...
src/test/java/com/itfsw/mybatis/generator/plugins/tools/DBHelper.java
View file @
26afb426
...
...
@@ -21,10 +21,7 @@ import org.apache.ibatis.session.SqlSession;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.apache.ibatis.session.SqlSessionFactoryBuilder
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.*
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
...
...
@@ -58,6 +55,7 @@ public class DBHelper {
helper
=
new
DBHelper
();
helper
.
initDB
(
initSql
);
}
cleanDao
();
return
helper
;
}
...
...
@@ -110,7 +108,35 @@ public class DBHelper {
/**
* 重置
*/
public
void
reset
(){
public
static
void
reset
(){
helper
=
null
;
cleanDao
();
}
/**
* 清理Dao空间
*/
public
static
void
cleanDao
(){
delDir
(
new
File
(
"src/test/java/com/itfsw/mybatis/generator/plugins/dao"
));
}
/**
* 清理工作区间
*
* @param file
*/
private
static
void
delDir
(
File
file
)
{
if
(
file
.
exists
()){
if
(
file
.
isFile
()){
file
.
delete
();
}
else
if
(
file
.
isDirectory
()){
File
[]
files
=
file
.
listFiles
();
for
(
File
file1:
files
)
{
delDir
(
file1
);
}
file
.
delete
();
}
}
}
}
src/test/java/com/itfsw/mybatis/generator/plugins/tools/Util.java
0 → 100644
View file @
26afb426
/*
* Copyright (c) 2017.
*
* 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.
*/
package
com
.
itfsw
.
mybatis
.
generator
.
plugins
.
tools
;
import
java.lang.reflect.ParameterizedType
;
import
java.lang.reflect.Type
;
/**
* ---------------------------------------------------------------------------
*
* ---------------------------------------------------------------------------
* @author: hewei
* @time:2017/6/27 16:47
* ---------------------------------------------------------------------------
*/
public
class
Util
{
/**
* 获取List 泛型参数
*
* @param type
* @return
*/
public
static
String
getListActualType
(
Type
type
){
if
(
type
instanceof
ParameterizedType
){
Type
[]
actualTypeArguments
=
((
ParameterizedType
)
type
).
getActualTypeArguments
();
if
(
actualTypeArguments
.
length
==
1
){
return
actualTypeArguments
[
0
].
getTypeName
();
}
}
return
null
;
}
}
src/test/resources/scripts/BatchInsertPlugin/init.sql
View file @
26afb426
...
...
@@ -10,7 +10,7 @@ Target Server Type : MYSQL
Target Server Version : 50617
File Encoding : 65001
Date: 2017-06-2
6 17:30:13
Date: 2017-06-2
7 11:17:08
*/
SET
FOREIGN_KEY_CHECKS
=
0
;
...
...
@@ -22,5 +22,57 @@ DROP TABLE IF EXISTS `tb`;
CREATE
TABLE
`tb`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'注释1'
,
`field1`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'注释2'
,
`field2`
float
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
;
\ No newline at end of file
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
;
-- ----------------------------
-- Records of tb
-- ----------------------------
-- ----------------------------
-- Table structure for tb_blobs
-- ----------------------------
DROP
TABLE
IF
EXISTS
`tb_blobs`
;
CREATE
TABLE
`tb_blobs`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'注释1'
,
`field1`
varchar
(
255
)
DEFAULT
NULL
,
`field2`
longtext
COMMENT
'注释2'
,
`field3`
longtext
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
;
-- ----------------------------
-- Records of tb_blobs
-- ----------------------------
-- ----------------------------
-- Table structure for tb_keys
-- ----------------------------
DROP
TABLE
IF
EXISTS
`tb_keys`
;
CREATE
TABLE
`tb_keys`
(
`key1`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'注释1'
,
`key2`
varchar
(
255
)
NOT
NULL
,
`field1`
varchar
(
255
)
DEFAULT
NULL
COMMENT
'注释2'
,
`field2`
float
DEFAULT
NULL
,
PRIMARY
KEY
(
`key1`
,
`key2`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
;
-- ----------------------------
-- Records of tb_keys
-- ----------------------------
-- ----------------------------
-- Table structure for tb_single_blob
-- ----------------------------
DROP
TABLE
IF
EXISTS
`tb_single_blob`
;
CREATE
TABLE
`tb_single_blob`
(
`id`
bigint
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'注释1'
,
`field1`
longtext
COMMENT
'注释2'
,
`field2`
float
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
;
-- ----------------------------
-- Records of tb_single_blob
-- ----------------------------
src/test/resources/scripts/BatchInsertPlugin/mybatis-generator-with-error-driver.xml
View file @
26afb426
...
...
@@ -33,19 +33,19 @@
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.model"
targetProject=
"src/
main
/java"
>
<javaModelGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.model"
targetProject=
"src/
test
/java"
>
<!-- 是否对model添加 构造函数 -->
<property
name=
"constructorBased"
value=
"true"
/>
<!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.mapping"
targetProject=
"src/
main
/java"
/>
<sqlMapGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.mapping"
targetProject=
"src/
test
/java"
/>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao"
targetProject=
"src/
main
/java"
type=
"XMLMAPPER"
/>
<javaClientGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao"
targetProject=
"src/
test
/java"
type=
"XMLMAPPER"
/>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 要自动生成的表 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<table
tableName=
"tb"
>
...
...
src/test/resources/scripts/BatchInsertPlugin/mybatis-generator-without-model-column-plugin.xml
View file @
26afb426
...
...
@@ -31,19 +31,19 @@
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.model"
targetProject=
"src/
main
/java"
>
<javaModelGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.model"
targetProject=
"src/
test
/java"
>
<!-- 是否对model添加 构造函数 -->
<property
name=
"constructorBased"
value=
"true"
/>
<!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.mapping"
targetProject=
"src/
main
/java"
/>
<sqlMapGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.mapping"
targetProject=
"src/
test
/java"
/>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao"
targetProject=
"src/
main
/java"
type=
"XMLMAPPER"
/>
<javaClientGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao"
targetProject=
"src/
test
/java"
type=
"XMLMAPPER"
/>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 要自动生成的表 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<table
tableName=
"tb"
>
...
...
src/test/resources/scripts/BatchInsertPlugin/mybatis-generator.xml
0 → 100644
View file @
26afb426
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2017.
~
~ 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.BatchInsertPlugin"
/>
<!-- 数据Model属性对应Column获取插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.ModelColumnPlugin"
/>
<!--jdbc的数据库连接 -->
<jdbcConnection
driverClass=
"${db.driver}"
connectionURL=
"${db.url}"
userId=
"${db.username}"
password=
"${db.password}"
/>
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.model"
targetProject=
"src/test/java"
>
<!-- 是否对model添加 构造函数 -->
<property
name=
"constructorBased"
value=
"true"
/>
<!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.mapping"
targetProject=
"src/test/java"
/>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao"
targetProject=
"src/test/java"
type=
"XMLMAPPER"
/>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 要自动生成的表 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<table
tableName=
"tb"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
<table
tableName=
"tb_keys"
/>
<table
tableName=
"tb_single_blob"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
<table
tableName=
"tb_blobs"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
src/test/resources/scripts/ExampleTargetPlugin/mybatis-generator-without-plugin.xml
View file @
26afb426
...
...
@@ -29,19 +29,19 @@
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.model"
targetProject=
"src/
main
/java"
>
<javaModelGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.model"
targetProject=
"src/
test
/java"
>
<!-- 是否对model添加 构造函数 -->
<property
name=
"constructorBased"
value=
"true"
/>
<!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.mapping"
targetProject=
"src/
main
/java"
/>
<sqlMapGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.mapping"
targetProject=
"src/
test
/java"
/>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao"
targetProject=
"src/
main
/java"
type=
"XMLMAPPER"
/>
<javaClientGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao"
targetProject=
"src/
test
/java"
type=
"XMLMAPPER"
/>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 要自动生成的表 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<table
tableName=
"tb"
>
...
...
src/test/resources/scripts/ExampleTargetPlugin/mybatis-generator.xml
View file @
26afb426
...
...
@@ -34,19 +34,19 @@
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 -->
<javaModelGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.model"
targetProject=
"src/
main
/java"
>
<javaModelGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.model"
targetProject=
"src/
test
/java"
>
<!-- 是否对model添加 构造函数 -->
<property
name=
"constructorBased"
value=
"true"
/>
<!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 -->
<sqlMapGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.mapping"
targetProject=
"src/
main
/java"
/>
<sqlMapGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao.mapping"
targetProject=
"src/
test
/java"
/>
<!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao"
targetProject=
"src/
main
/java"
type=
"XMLMAPPER"
/>
<javaClientGenerator
targetPackage=
"com.itfsw.mybatis.generator.plugins.dao"
targetProject=
"src/
test
/java"
type=
"XMLMAPPER"
/>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 要自动生成的表 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<table
tableName=
"tb"
>
...
...
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