Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
432b834985 | ||
|
|
dd34ea5c6b | ||
|
|
7df2d4e27f | ||
|
|
42f6a2ce28 | ||
|
|
2a75e9cf53 | ||
|
|
fab929d352 | ||
|
|
39568d91af | ||
|
|
b4b645964f | ||
|
|
5c5c7765b8 | ||
|
|
f3be4ea6dc | ||
|
|
37161f24b3 | ||
|
|
1d1c7b10b9 |
@@ -34,7 +34,7 @@ Maven引用:
|
||||
<dependency>
|
||||
<groupId>com.itfsw</groupId>
|
||||
<artifactId>mybatis-generator-plugin</artifactId>
|
||||
<version>1.2.14</version>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
```
|
||||
---------------------------------------
|
||||
@@ -89,7 +89,7 @@ targetCompatibility = 1.8
|
||||
|
||||
|
||||
def mybatisGeneratorCore = 'org.mybatis.generator:mybatis-generator-core:1.3.7'
|
||||
def itfswMybatisGeneratorPlugin = 'com.itfsw:mybatis-generator-plugin:1.2.14'
|
||||
def itfswMybatisGeneratorPlugin = 'com.itfsw:mybatis-generator-plugin:1.2.17'
|
||||
|
||||
mybatisGenerator {
|
||||
verbose = false
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<groupId>com.itfsw</groupId>
|
||||
<artifactId>mybatis-generator-plugin</artifactId>
|
||||
<version>1.2.15</version>
|
||||
<version>1.2.18-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
@@ -97,16 +97,24 @@
|
||||
<version>[1.18.2,)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- lombok dependency -->
|
||||
<!-- lombok 的测试用例依赖tools.jar, 但直接使用以下方式配置会导致gradle报错
|
||||
解决办法:把tools.jar 安装进本地仓库!!
|
||||
mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dpackaging=jar -Dversion=1.8 -Dfile=tools.jar
|
||||
<dependency>
|
||||
<groupId>com.sun</groupId>
|
||||
<artifactId>tools</artifactId>
|
||||
<version>1.8</version>
|
||||
<scope>system</scope>
|
||||
<optional>true</optional>
|
||||
<!-- jdk path -->
|
||||
<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>jdk.tools</groupId>
|
||||
<artifactId>jdk.tools</artifactId>
|
||||
<version>1.8</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++profiles++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
@@ -234,7 +242,7 @@
|
||||
<connection>scm:git:https://github.com/itfsw/mybatis-generator-plugin.git</connection>
|
||||
<developerConnection>scm:git:https://github.com/itfsw/mybatis-generator-plugin.git</developerConnection>
|
||||
<url>https://github.com/itfsw/mybatis-generator-plugin</url>
|
||||
<tag>V1.2.15</tag>
|
||||
<tag>V1.2.6</tag>
|
||||
</scm>
|
||||
|
||||
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++distribution++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||
|
||||
@@ -177,10 +177,10 @@ public class LogicalDeletePlugin extends BasePlugin {
|
||||
warnings.add("itfsw(逻辑删除插件):" + introspectedTable.getFullyQualifiedTable() + "没有找到您配置的逻辑删除值,请全局或者局部配置logicalDeleteValue和logicalUnDeleteValue值!");
|
||||
} else {
|
||||
// 兼容处理以前一些老用户配置的Long 和 Float配置问题
|
||||
if (this.logicalDeleteColumn.getFullyQualifiedJavaType().getFullyQualifiedName().equals(Long.class.getName())){
|
||||
if (this.logicalDeleteColumn.getFullyQualifiedJavaType().getFullyQualifiedName().equals(Long.class.getName())) {
|
||||
this.logicalUnDeleteValue = this.logicalUnDeleteValue.replaceAll("L|l", "");
|
||||
this.logicalDeleteValue = this.logicalDeleteValue.replaceAll("L|l", "");
|
||||
} else if (this.logicalDeleteColumn.getFullyQualifiedJavaType().getFullyQualifiedName().equals(Float.class.getName())){
|
||||
} else if (this.logicalDeleteColumn.getFullyQualifiedJavaType().getFullyQualifiedName().equals(Float.class.getName())) {
|
||||
this.logicalUnDeleteValue = this.logicalUnDeleteValue.replaceAll("F|f", "");
|
||||
this.logicalDeleteValue = this.logicalDeleteValue.replaceAll("F|f", "");
|
||||
}
|
||||
@@ -485,8 +485,8 @@ public class LogicalDeletePlugin extends BasePlugin {
|
||||
|
||||
// 常量放在字段开头
|
||||
ArrayList<Field> fields = (ArrayList<Field>) topLevelClass.getFields();
|
||||
fields.add(logicalUnDeleteConstField);
|
||||
fields.add(logicalDeleteConstField);
|
||||
fields.add(0, logicalUnDeleteConstField);
|
||||
fields.add(0, logicalDeleteConstField);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,19 +352,28 @@ public class SelectiveEnhancedPlugin extends BasePlugin implements IUpsertPlugin
|
||||
|
||||
@Override
|
||||
public boolean clientUpdateWithVersionByExampleSelectiveMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
|
||||
// column枚举,找出全字段对应的Model
|
||||
FullyQualifiedJavaType fullFieldModel = introspectedTable.getRules().calculateAllFieldsClass();
|
||||
FullyQualifiedJavaType selectiveType = new FullyQualifiedJavaType(fullFieldModel.getShortName() + "." + ModelColumnPlugin.ENUM_NAME);
|
||||
method.addParameter(new Parameter(selectiveType, "selective", "@Param(\"selective\")", true));
|
||||
// issue#69 OptimisticLockerPlugin 插件updateWithVersionByExampleSelective方法的生成是基于updateByExampleSelective的,
|
||||
// 这个方法在配置了SelectiveEnhancedPlugin时可能已经被先配置的SelectiveEnhancedPlugin改变了
|
||||
if (!"selective".equals(method.getParameters().get(method.getParameters().size() - 1).getName())) {
|
||||
// column枚举,找出全字段对应的Model
|
||||
FullyQualifiedJavaType fullFieldModel = introspectedTable.getRules().calculateAllFieldsClass();
|
||||
FullyQualifiedJavaType selectiveType = new FullyQualifiedJavaType(fullFieldModel.getShortName() + "." + ModelColumnPlugin.ENUM_NAME);
|
||||
method.addParameter(new Parameter(selectiveType, "selective", "@Param(\"selective\")", true));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clientUpdateWithVersionByPrimaryKeySelectiveMethodGenerated(Method method, Interface interfaze, IntrospectedTable introspectedTable) {
|
||||
// column枚举,找出全字段对应的Model
|
||||
FullyQualifiedJavaType fullFieldModel = introspectedTable.getRules().calculateAllFieldsClass();
|
||||
FullyQualifiedJavaType selectiveType = new FullyQualifiedJavaType(fullFieldModel.getShortName() + "." + ModelColumnPlugin.ENUM_NAME);
|
||||
method.addParameter(new Parameter(selectiveType, "selective", "@Param(\"selective\")", true));
|
||||
// issue#69 OptimisticLockerPlugin 插件updateWithVersionByExampleSelective方法的生成是基于updateByExampleSelective的,
|
||||
// 这个方法在配置了SelectiveEnhancedPlugin时可能已经被先配置的SelectiveEnhancedPlugin改变了
|
||||
if (!"selective".equals(method.getParameters().get(method.getParameters().size() - 1).getName())) {
|
||||
// column枚举,找出全字段对应的Model
|
||||
FullyQualifiedJavaType fullFieldModel = introspectedTable.getRules().calculateAllFieldsClass();
|
||||
FullyQualifiedJavaType selectiveType = new FullyQualifiedJavaType(fullFieldModel.getShortName() + "." + ModelColumnPlugin.ENUM_NAME);
|
||||
method.addParameter(new Parameter(selectiveType, "selective", "@Param(\"selective\")", true));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.mybatis.generator.api.GeneratedJavaFile;
|
||||
import org.mybatis.generator.api.MyBatisGenerator;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -155,9 +156,63 @@ public class BugFixedTest {
|
||||
MyBatisGenerator generator = tool.generate(() -> DBHelper.createDB("scripts/BugFixedTest/issues-63.sql"));
|
||||
for (GeneratedJavaFile file : generator.getGeneratedJavaFiles()) {
|
||||
String fileName = file.getFileName();
|
||||
if (fileName.startsWith("Repaydetail")){
|
||||
if (fileName.startsWith("Repaydetail")) {
|
||||
Assert.assertTrue("官方自己的问题", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 乐观锁插件配合SelectiveEnhancedPlugin多生成了selective参数的问题
|
||||
* https://github.com/itfsw/mybatis-generator-plugin/issues/69
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void issues69() throws Exception {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/BugFixedTest/issues-69-" + i + ".xml");
|
||||
tool.generate(() -> DBHelper.createDB("scripts/BugFixedTest/issues-69.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", 1l);
|
||||
|
||||
ObjectUtil tb = new ObjectUtil(loader, packagz + ".Tb");
|
||||
tb.set("id", 1L);
|
||||
tb.set("version", 152L);
|
||||
tb.set("incF2", 10L);
|
||||
tb.set("incF3", 5L);
|
||||
|
||||
// selective
|
||||
ObjectUtil TbColumnId = new ObjectUtil(loader, packagz + ".Tb$Column#id");
|
||||
ObjectUtil TbColumnVersion = new ObjectUtil(loader, packagz + ".Tb$Column#version");
|
||||
ObjectUtil TbColumnIncF2 = new ObjectUtil(loader, packagz + ".Tb$Column#incF2");
|
||||
Object columns = Array.newInstance(TbColumnId.getCls(), 3);
|
||||
Array.set(columns, 0, TbColumnId.getObject());
|
||||
Array.set(columns, 1, TbColumnVersion.getObject());
|
||||
Array.set(columns, 2, TbColumnIncF2.getObject());
|
||||
|
||||
// sql
|
||||
String sql = SqlHelper.getFormatMapperSql(tbMapper.getObject(), "updateWithVersionByExampleSelective", 100L, tb.getObject(), tbExample.getObject(), columns);
|
||||
Assert.assertEquals(sql, "update tb SET version = version + 1, id = 1 , inc_f2 = 10 WHERE version = 100 and ( ( id = '1' ) )");
|
||||
|
||||
// 执行一次,因为版本号100不存在所以应该返回0
|
||||
Object result = tbMapper.invoke("updateWithVersionByExampleSelective", 100L, tb.getObject(), tbExample.getObject(), columns);
|
||||
Assert.assertEquals(result, 0);
|
||||
|
||||
// id = 1 的版本号应该是0
|
||||
result = tbMapper.invoke("updateWithVersionByExampleSelective", 0L, tb.getObject(), tbExample.getObject(), columns);
|
||||
Assert.assertEquals(result, 1);
|
||||
|
||||
// 执行完成后版本号应该加1
|
||||
ResultSet rs = DBHelper.execute(sqlSession.getConnection(), "select * from tb where id = 1");
|
||||
rs.first();
|
||||
Assert.assertEquals(rs.getInt("version"), 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CommentPluginTest {
|
||||
*/
|
||||
@BeforeClass
|
||||
public static void init() throws Exception {
|
||||
DBHelper.createDB("scripts/ComentPlugin/init.sql");
|
||||
DBHelper.createDB("scripts/CommentPlugin/init.sql");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ public class CommentPluginTest {
|
||||
*/
|
||||
@Test
|
||||
public void testGenerateWithoutTemplate() throws Exception {
|
||||
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ComentPlugin/mybatis-generator-without-template.xml");
|
||||
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/CommentPlugin/mybatis-generator-without-template.xml");
|
||||
MyBatisGenerator myBatisGenerator = tool.generate();
|
||||
// 是否在使用系统默认模板
|
||||
int count = 0;
|
||||
@@ -76,7 +76,7 @@ public class CommentPluginTest {
|
||||
*/
|
||||
@Test
|
||||
public void testGenerateWithTemplate() throws Exception {
|
||||
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/ComentPlugin/mybatis-generator.xml");
|
||||
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/CommentPlugin/mybatis-generator.xml");
|
||||
MyBatisGenerator myBatisGenerator = tool.generate();
|
||||
|
||||
// java中的注释
|
||||
@@ -105,4 +105,31 @@ public class CommentPluginTest {
|
||||
String comment = ((TextElement) els.get(0)).getContent();
|
||||
Assert.assertEquals(comment, "addComment:BaseResultMap");
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试配置了模板参数转换
|
||||
*/
|
||||
@Test
|
||||
public void testGenerateWithOutComment() throws Exception {
|
||||
MyBatisGeneratorTool tool = MyBatisGeneratorTool.create("scripts/CommentPlugin/mybatis-generator-without-comment.xml");
|
||||
MyBatisGenerator myBatisGenerator = tool.generate();
|
||||
|
||||
// java中的注释
|
||||
for (GeneratedJavaFile file : myBatisGenerator.getGeneratedJavaFiles()) {
|
||||
if (file.getFileName().equals("Tb.java")) {
|
||||
TopLevelClass topLevelClass = (TopLevelClass) file.getCompilationUnit();
|
||||
// addJavaFileComment
|
||||
Assert.assertEquals(topLevelClass.getFileCommentLines().size(), 0);
|
||||
// addFieldComment
|
||||
Field id = topLevelClass.getFields().get(0);
|
||||
Assert.assertEquals(id.getJavaDocLines().size(), 0);
|
||||
// addGeneralMethodComment
|
||||
Method cons = topLevelClass.getMethods().get(0);
|
||||
Assert.assertEquals(cons.getJavaDocLines().size(), 0);
|
||||
// addSetterComment
|
||||
Method setter = topLevelClass.getMethods().get(5);
|
||||
Assert.assertEquals(setter.getJavaDocLines().size(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2019.
|
||||
~
|
||||
~ 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">
|
||||
<property name="autoDelimitKeywords" value="true"/>
|
||||
<property name="beginningDelimiter" value="`"/>
|
||||
<property name="endingDelimiter" value="`"/>
|
||||
|
||||
<!-- 乐观锁插件 -->
|
||||
<plugin type="com.itfsw.mybatis.generator.plugins.OptimisticLockerPlugin"/>
|
||||
<!-- 数据Model属性对应Column获取插件 -->
|
||||
<plugin type="com.itfsw.mybatis.generator.plugins.ModelColumnPlugin"/>
|
||||
<!-- Selective选择插入更新增强插件 -->
|
||||
<plugin type="com.itfsw.mybatis.generator.plugins.SelectiveEnhancedPlugin"/>
|
||||
|
||||
|
||||
<!--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">
|
||||
<property name="versionColumn" value="version"/>
|
||||
</table>
|
||||
</context>
|
||||
</generatorConfiguration>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2019.
|
||||
~
|
||||
~ 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">
|
||||
<property name="autoDelimitKeywords" value="true"/>
|
||||
<property name="beginningDelimiter" value="`"/>
|
||||
<property name="endingDelimiter" value="`"/>
|
||||
|
||||
<!-- 数据Model属性对应Column获取插件 -->
|
||||
<plugin type="com.itfsw.mybatis.generator.plugins.ModelColumnPlugin"/>
|
||||
<!-- Selective选择插入更新增强插件 -->
|
||||
<plugin type="com.itfsw.mybatis.generator.plugins.SelectiveEnhancedPlugin"/>
|
||||
<!-- 乐观锁插件 -->
|
||||
<plugin type="com.itfsw.mybatis.generator.plugins.OptimisticLockerPlugin"/>
|
||||
|
||||
<!--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">
|
||||
<property name="versionColumn" value="version"/>
|
||||
</table>
|
||||
</context>
|
||||
</generatorConfiguration>
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Navicat MySQL Data Transfer
|
||||
|
||||
Source Server : localhost
|
||||
Source Server Version : 50617
|
||||
Source Host : localhost:3306
|
||||
Source Database : mybatis-generator-plugin
|
||||
|
||||
Target Server Type : MYSQL
|
||||
Target Server Version : 50617
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 2017-07-05 17:21:41
|
||||
*/
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for tb
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `tb`;
|
||||
CREATE TABLE `tb` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '注释1',
|
||||
`field1` varchar(255) DEFAULT NULL COMMENT '注释2',
|
||||
`version` bigint(20) NOT NULL DEFAULT '0',
|
||||
`inc_f2` bigint(20) DEFAULT '0',
|
||||
`inc_f3` bigint(20) DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of tb
|
||||
-- ----------------------------
|
||||
INSERT INTO `tb` VALUES ('1', 'fd1', '0', '2', '0');
|
||||
INSERT INTO `tb` VALUES ('2', 'fd2', '1', '2', '3');
|
||||
INSERT INTO `tb` VALUES ('3', null, '3', '2', '1');
|
||||
INSERT INTO `tb` VALUES ('4', 'fd3', '1', '1', '1');
|
||||
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2019.
|
||||
~
|
||||
~ 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.CommentPlugin"/>
|
||||
|
||||
<commentGenerator>
|
||||
<property name="suppressAllComments" value="true"/>
|
||||
</commentGenerator>
|
||||
<!--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>
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
<!-- 插件 -->
|
||||
<!-- 注释插件 -->
|
||||
<plugin type="com.itfsw.mybatis.generator.plugins.CommentPlugin">
|
||||
<property name="template" value="src/test/resources/scripts/ComentPlugin/test-comment.ftl"/>
|
||||
<property name="template" value="src/test/resources/scripts/CommentPlugin/test-comment.ftl"/>
|
||||
</plugin>
|
||||
|
||||
<commentGenerator>
|
||||
Reference in New Issue
Block a user