Commit 26afb426 authored by hewei's avatar hewei

继续完善测试用例

parent cec43949
...@@ -13,3 +13,4 @@ hs_err_pid* ...@@ -13,3 +13,4 @@ hs_err_pid*
.idea/ .idea/
mybatis-generator-plugin.iml mybatis-generator-plugin.iml
target/ target/
src/main/java/com/itfsw/mybatis/generator/plugins/dao/
\ No newline at end of file
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
<artifactId>dom4j</artifactId> <artifactId>dom4j</artifactId>
<version>1.6.1</version> <version>1.6.1</version>
</dependency> </dependency>
<!-- ############################### test ############################ -->
<!-- junit --> <!-- junit -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
...@@ -78,6 +79,12 @@ ...@@ -78,6 +79,12 @@
<version>5.1.40</version> <version>5.1.40</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.4.0</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++profiles++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++profiles++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
......
...@@ -16,9 +16,11 @@ ...@@ -16,9 +16,11 @@
package com.itfsw.mybatis.generator.plugins; 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.DBHelper;
import com.itfsw.mybatis.generator.plugins.tools.Util;
import org.apache.ibatis.io.Resources; import org.apache.ibatis.io.Resources;
import org.junit.After; import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
...@@ -30,6 +32,7 @@ import org.mybatis.generator.exception.XMLParserException; ...@@ -30,6 +32,7 @@ import org.mybatis.generator.exception.XMLParserException;
import org.mybatis.generator.internal.DefaultShellCallback; import org.mybatis.generator.internal.DefaultShellCallback;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -83,8 +86,58 @@ public class BatchInsertPluginTest { ...@@ -83,8 +86,58 @@ public class BatchInsertPluginTest {
Assert.assertEquals(warnings.get(1), "itfsw:插件com.itfsw.mybatis.generator.plugins.BatchInsertPlugin插件使用前提是数据库为MySQL或者SQLserver,因为返回主键使用了JDBC的getGenereatedKeys方法获取主键!"); Assert.assertEquals(warnings.get(1), "itfsw:插件com.itfsw.mybatis.generator.plugins.BatchInsertPlugin插件使用前提是数据库为MySQL或者SQLserver,因为返回主键使用了JDBC的getGenereatedKeys方法获取主键!");
} }
@After @Test
public void clean(){ public void testMethods() throws IOException, XMLParserException, InvalidConfigurationException, SQLException, InterruptedException, ClassNotFoundException, NoSuchMethodException {
helper.reset(); 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();
} }
} }
...@@ -59,6 +59,6 @@ public class DBHelperTest { ...@@ -59,6 +59,6 @@ public class DBHelperTest {
statement.close(); statement.close();
connection.close(); connection.close();
sqlSession.close(); sqlSession.close();
helper.reset(); DBHelper.reset();
} }
} }
...@@ -92,6 +92,6 @@ public class ExampleTargetPluginTest { ...@@ -92,6 +92,6 @@ public class ExampleTargetPluginTest {
@After @After
public void clean(){ public void clean(){
helper.reset(); DBHelper.reset();
} }
} }
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.itfsw.mybatis.generator.plugins.tools; package com.itfsw.mybatis.generator.plugins.tools;
import org.junit.Assert;
import org.mybatis.generator.api.ShellCallback; import org.mybatis.generator.api.ShellCallback;
import org.mybatis.generator.exception.ShellException; import org.mybatis.generator.exception.ShellException;
...@@ -62,8 +63,7 @@ public abstract class AbstractShellCallback implements ShellCallback { ...@@ -62,8 +63,7 @@ public abstract class AbstractShellCallback implements ShellCallback {
*/ */
@Override @Override
public void refreshProject(String project) { public void refreshProject(String project) {
String daoDir = project + "/com/itfsw/mybatis/generator/plugins/dao"; List<File> files = getJavaFiles(new File(project + "/com/itfsw/mybatis/generator/plugins/dao"));
List<File> files = getJavaFiles(new File(daoDir));
if (!files.isEmpty()) { if (!files.isEmpty()) {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
...@@ -80,9 +80,10 @@ public abstract class AbstractShellCallback implements ShellCallback { ...@@ -80,9 +80,10 @@ public abstract class AbstractShellCallback implements ShellCallback {
task.call(); task.call();
try { try {
reloadProject(new URLClassLoader(new URL[]{new URL(daoDir)})); reloadProject(new URLClassLoader(new URL[]{new File(project).toURI().toURL()}));
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
Assert.assertTrue(false);
} }
} else { } else {
reloadProject(this.getClass().getClassLoader()); reloadProject(this.getClass().getClassLoader());
......
...@@ -21,10 +21,7 @@ import org.apache.ibatis.session.SqlSession; ...@@ -21,10 +21,7 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder; import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import java.io.BufferedReader; import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
...@@ -58,6 +55,7 @@ public class DBHelper { ...@@ -58,6 +55,7 @@ public class DBHelper {
helper = new DBHelper(); helper = new DBHelper();
helper.initDB(initSql); helper.initDB(initSql);
} }
cleanDao();
return helper; return helper;
} }
...@@ -110,7 +108,35 @@ public class DBHelper { ...@@ -110,7 +108,35 @@ public class DBHelper {
/** /**
* 重置 * 重置
*/ */
public void reset(){ public static void reset(){
helper = null; 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();
}
}
} }
} }
/*
* 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;
}
}
...@@ -10,7 +10,7 @@ Target Server Type : MYSQL ...@@ -10,7 +10,7 @@ Target Server Type : MYSQL
Target Server Version : 50617 Target Server Version : 50617
File Encoding : 65001 File Encoding : 65001
Date: 2017-06-26 17:30:13 Date: 2017-06-27 11:17:08
*/ */
SET FOREIGN_KEY_CHECKS=0; SET FOREIGN_KEY_CHECKS=0;
...@@ -22,5 +22,57 @@ DROP TABLE IF EXISTS `tb`; ...@@ -22,5 +22,57 @@ DROP TABLE IF EXISTS `tb`;
CREATE TABLE `tb` ( CREATE TABLE `tb` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '注释1', `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '注释1',
`field1` varchar(255) DEFAULT NULL COMMENT '注释2', `field1` varchar(255) DEFAULT NULL COMMENT '注释2',
`field2` float DEFAULT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\ No newline at end of file
-- ----------------------------
-- 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
-- ----------------------------
...@@ -33,19 +33,19 @@ ...@@ -33,19 +33,19 @@
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类 <!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名 targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 --> 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添加 构造函数 --> <!-- 是否对model添加 构造函数 -->
<property name="constructorBased" value="true"/> <property name="constructorBased" value="true"/>
<!-- 给Model添加一个父类 --> <!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>--> <!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator> </javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 --> <!--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配置文件 的代码 <!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象 type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象 type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的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"> <table tableName="tb">
......
...@@ -31,19 +31,19 @@ ...@@ -31,19 +31,19 @@
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类 <!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名 targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 --> 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添加 构造函数 --> <!-- 是否对model添加 构造函数 -->
<property name="constructorBased" value="true"/> <property name="constructorBased" value="true"/>
<!-- 给Model添加一个父类 --> <!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>--> <!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator> </javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 --> <!--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配置文件 的代码 <!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象 type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象 type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的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"> <table tableName="tb">
......
<?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
...@@ -29,19 +29,19 @@ ...@@ -29,19 +29,19 @@
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类 <!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名 targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 --> 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添加 构造函数 --> <!-- 是否对model添加 构造函数 -->
<property name="constructorBased" value="true"/> <property name="constructorBased" value="true"/>
<!-- 给Model添加一个父类 --> <!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>--> <!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator> </javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 --> <!--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配置文件 的代码 <!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象 type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象 type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的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"> <table tableName="tb">
......
...@@ -34,19 +34,19 @@ ...@@ -34,19 +34,19 @@
<!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类 <!-- Model模型生成器,用来生成含有主键key的类,记录类 以及查询Example类
targetPackage 指定生成的model生成所在的包名 targetPackage 指定生成的model生成所在的包名
targetProject 指定在该项目下所在的路径 --> 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添加 构造函数 --> <!-- 是否对model添加 构造函数 -->
<property name="constructorBased" value="true"/> <property name="constructorBased" value="true"/>
<!-- 给Model添加一个父类 --> <!-- 给Model添加一个父类 -->
<!--<property name="rootClass" value="com.itfsw.base"/>--> <!--<property name="rootClass" value="com.itfsw.base"/>-->
</javaModelGenerator> </javaModelGenerator>
<!--Mapper映射文件生成所在的目录 为每一个数据库的表生成对应的SqlMap文件 --> <!--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配置文件 的代码 <!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件 的代码
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象 type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象 type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的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"> <table tableName="tb">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment