正常情况下mybatis-generator-core中为变量自动生成注释时需要getRemarks(),获取表字段的注释
一般情况下是取不出来的
需要修改一下mybatis-generator-core 的源代码
mybatis-generator-core/src/main/java/org/mybatis/generator/internal/db/ConnectionFactory.java
中的public Connection getConnection(JDBCConnectionConfiguration config)方法:
添加上几行代码:
// 获取Oracle元数据 REMARKS信息
props.setProperty("remarksReporting","true");
// 获取MySQL元数据 REMARKS信息
props.setProperty("useInformationSchema","true");
eg:
public Connection getConnection(JDBCConnectionConfiguration config)
throws SQLException {
Driver driver = getDriver(config);
Properties props = new Properties();
if (stringHasValue(config.getUserId())) {
props.setProperty("user", config.getUserId()); //$NON-NLS-1$
}
if (stringHasValue(config.getPassword())) {
props.setProperty("password", config.getPassword()); //$NON-NLS-1$
}
// 获取Oracle元数据 REMARKS信息
props.setProperty("remarksReporting","true");
// 获取MySQL元数据 REMARKS信息
props.setProperty("useInformationSchema","true"); </span>
props.putAll(config.getProperties());
Connection conn = driver.connect(config.getConnectionURL(), props);
if (conn == null) {
throw new SQLException(getString("RuntimeError.7")); //$NON-NLS-1$
}
return conn;
}