默认的 MyBatis Generator 生成实体类的时候,字段不会带上数据库已有的注释。此时可以扩展 MyBatis Generator ,使生成的实体类带上数据库已有的注释。 继承 org.mybatis.generator.internal.DefaultCommentGenerator 类 public class DatabaseRemarkCommentGenerator extends DefaultCommentGenerator { @Override public void addFieldComment ( Field field , IntrospectedTable introspectedTable , IntrospectedColumn introspectedColumn ) { if ( introspectedColumn . getRemarks ( ) != null && ! introspectedColumn . getRemarks ( ) . equals ( "" ) ) { field . addJavaDocLine ( "/**" ) ; field . addJavaDocLine ( " * " + introspectedColumn . getRemarks ( ) ) ; field . addJavaDocLine ( " */" ) ; } } } 把上述代码放入 MyBatis Generator 的 CLASSPATH 中。 修改配置文件 generatorConfig.xml ,把 commentGenerator 标签的 type 属性修改为刚才实现的类 < commentGenerator type = " org.mybatis.generator.plugin.DatabaseRemarkCommentGenerator " > < property