由于最新改用mybatis框架 故从网上down下该插件,试用以下,确实好用。
但是在用的过程中发现几点问题:
1. 发现supressAllComments(阻止生成注释,true为不生成)改为false后,还是不好使,看源码得知addRemarkComments 这个参数必须声明为true
2.默认的注释器会有许多我个人用不到的信息 故修改其类为自定义的MyCommentGenerator
<commentGenerator type="org.mybatis.generator.internal.MyCommentGenerator"> <property name="suppressDate" value="true"/> <property name="suppressAllComments" value="false"/> <property name="addRemarkComments" value="true"/> <!-- If suppressAllComments is true, this option is ignored. --> <!-- 生成的Java文件的编码 --> <property name="javaFileEncoding" value="UTF-8"/> <!-- 格式化java代码 --> <property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter"/> <!-- 格式化XML代码 --> <property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/> </commentGenerator>
3.使用的同学可能也发现了就是有时候生成的实体类会缺少字段,(我用的oracle),跟踪源码发现,在查询表及表结构时会查到多个相同名称的tc_pos表,在细查发现,由于miliform用户的权限为sys级别的,可以查询其他的用户下的表,多人公用一个数据库,导致出现该问题,所以schema字段尽量加上后可解决。(该问题不知道会不会在mysql上出现,待测)
<table tableName="tc_pos" schema="miliform" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="false"></table>