目前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 啦

最新文章

  1. 如何将页面的&lt;br/&gt;在Excel中正确换行
  2. 【读书笔记】iOS-ARC-Xcode检测循环引用
  3. 安装MySQLdb
  4. Win7环境下Eclipse连接Hadoop2.2.0
  5. 分布式服务框架 Zookeeper -- 管理分布式环境中的数据
  6. .NET(Core)应用程序模型及未来
  7. 配置个舒心的 Java 开发环境
  8. node前端自动化
  9. 求和问题总结(leetcode 2Sum, 3Sum, 4Sum, K Sum)
  10. 【HDOJ】1561 The more, The Better
  11. 【iOS开发-76】Private Contacts案例:导航控制器使用、数据传递、第三方类库使用、tableViewCell的加入删除、数据存储等
  12. [Jenkins]admin用户登陆,提示登陆无效(之前登陆OK,三天没有登陆,突然提示登陆无效,重启无法解决)的解决方法
  13. python笔记十五(面向对象及其特性)
  14. 使用 Asp.net core 2.0 + Angular 4 构建车辆管理的Web应用程序
  15. easyui tree 更改图标
  16. py3中reduce
  17. Netty 心跳服务之 IdleStateHandler 源码分析
  18. django时区设置以及全球用户如何各自显示当地时间
  19. Apache Spark Exception in thread “main” java.lang.NoClassDefFoundError: scala/collection/GenTraversableOnce$class
  20. bzoj 3926 转换+广义后缀自动机

热门文章

  1. FreeMarker的基础语法
  2. 如何判断一个DOM元素正在动画,一个CSS“阻塞”JS的例子
  3. Undefined symbols for architecture arm64:
  4. iOS中的各种id
  5. Android requires compiler compliance level 5.0 or 6.0. Found &#39;1.4&#39; instead的解决办法
  6. [MySQL Reference Manual] 24 MySQL sys框架
  7. SQL Server封闭掉 触发器递归
  8. Git命令
  9. 配置WinRM的Https
  10. Java程序设计之Constructor