mybatis-generator指定列进行自动生成代码
2024-08-24 13:53:46
目前mybatis-generator已经升级到1.3.3,功能比较强大,但是目前从table中如果字段较多可以选择忽略生产的字段(通过ignoreColumn属性实现,http://generator.sturgeon.mopaas.com/configreference/ignoreColumn.html),如果一个table字段太多而只需要某几个字段,例如100个字段的表格中只要5个,
那么需要选择95个字段进行ignore,这样费时也费神,而且极容易出错,想想如果copy到第90个字段的时候,你的小伙伴往数据库插入了一个字段,于是你弄完95个字段后,兴致勃勃生成了代码.
测试环境一切正常,到了线上可能就报错了,那一个字段线上还没有.
基于此问题,如果可以支持指定字段生成就完美了.于是对源码进行了一定程度的修改.
github:https://github.com/candyleer/generator/tree/feature/candylee_requiredcolum
可以在配置文件进行如下配置,便可以只生成指定字段.
<table tableName="brands" domainObjectName="Brand" alias="b">
<requiredColumn column="title"/>
<requiredColumn column="hot"/>
</table>
ps:官方版本从1.3.4开始,支持此属性的配置,配置略有不同,配置如下:
http://www.mybatis.org/generator/configreference/ignoreColumnsByRegex.html
Example
This example tells MyBatis to ignore every column in the Foo table that begins with the characters "col" (case-insensitive) except for "col01" and "col13". <table tableName="Foo">
<ignoreColumnsByRegex pattern="(?i)col.*">
<except column="col01"/>
<except column="col13"/>
</ignoreColumnsByRegex>
</table>
可以使用官方配置,不用写诸多的ignore 啦
最新文章
- 如何将页面的<;br/>;在Excel中正确换行
- 【读书笔记】iOS-ARC-Xcode检测循环引用
- 安装MySQLdb
- Win7环境下Eclipse连接Hadoop2.2.0
- 分布式服务框架 Zookeeper -- 管理分布式环境中的数据
- .NET(Core)应用程序模型及未来
- 配置个舒心的 Java 开发环境
- node前端自动化
- 求和问题总结(leetcode 2Sum, 3Sum, 4Sum, K Sum)
- 【HDOJ】1561 The more, The Better
- 【iOS开发-76】Private Contacts案例:导航控制器使用、数据传递、第三方类库使用、tableViewCell的加入删除、数据存储等
- [Jenkins]admin用户登陆,提示登陆无效(之前登陆OK,三天没有登陆,突然提示登陆无效,重启无法解决)的解决方法
- python笔记十五(面向对象及其特性)
- 使用 Asp.net core 2.0 + Angular 4 构建车辆管理的Web应用程序
- easyui tree 更改图标
- py3中reduce
- Netty 心跳服务之 IdleStateHandler 源码分析
- django时区设置以及全球用户如何各自显示当地时间
- Apache Spark Exception in thread “main” java.lang.NoClassDefFoundError: scala/collection/GenTraversableOnce$class
- bzoj 3926 转换+广义后缀自动机
热门文章
- FreeMarker的基础语法
- 如何判断一个DOM元素正在动画,一个CSS“阻塞”JS的例子
- Undefined symbols for architecture arm64:
- iOS中的各种id
- Android requires compiler compliance level 5.0 or 6.0. Found &#39;1.4&#39; instead的解决办法
- [MySQL Reference Manual] 24 MySQL sys框架
- SQL Server封闭掉 触发器递归
- Git命令
- 配置WinRM的Https
- Java程序设计之Constructor