我们在使用xml进行mybatis的自动代码生成时是否出现一个问题。
- 想要在生成注释中带有数据库表中每列的注释,但又不想包含原生的繁琐英文注释
The <commentGenerator> Element
标签有以下几种属性
其中比较关键的一点是:addRemarkComments
中的
**Warning: **If suppressAllComments option is true, this option will be ignored.
意思是如果suppressAllComments
为true的话,也就是不用原生的注释。那么addRemarkComments
将会失效
代码解释
org.mybatis.generator.internal.DefaultCommentGenerator类中
public class DefaultCommentGenerator implements CommentGenerator {
/** The properties. */
private Properties properties;
/** The suppress date. */
private boolean suppressDate;
/** The suppress all comments. */
private boolean suppressAllComments;
/** The addition of table remark's comments.
* If suppressAllComments is true, this option is ignored*/
private boolean addRemarkComments;
/**
* Instantiates a new default comment generator.
*/
//初始时设置为false
public DefaultCommentGenerator() {
super();
properties = new Properties();
suppressDate = false;
suppressAllComments = false;
addRemarkComments = false;
}
//依据xml中的配置设置suppressDate, suppressAllComments,addRemarkComments
public void addConfigurationProperties(Properties properties) {
this.properties.putAll(properties);
suppressDate = isTrue(properties
.getProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_DATE));