mybatis-plus 中mapUnderscoreToCamelCase配置

mapUnderscoreToCamelCase

  • 类型:boolean
  • 默认值:true

是否开启自动驼峰命名规则(camel case)映射,即从经典数据库列名 A_COLUMN(下划线命名) 到经典 Java 属性名 aColumn(驼峰命名) 的类似映射。

注意:

1.此属性在 MyBatis 中原默认值为 false,在 MyBatis-Plus 中,此属性也将用于生成最终的 SQL 的 select body

2.如果数据库命名符合规则无需使用 @TableField 注解指定数据库字段名

mybatis-plus:
  configuration:
    map-underscore-to-camel-case: false

//当为true时:mybatis-plus会将Java对象的驼峰式命名的常量转成下划线的方式,再与数据库表列字段进行匹配,这样会造成错误。 此时需要利用@TableField注解指定常量在表中的列名。

//当为false时:此时就需要数据库里每列都是下划线的命名方式。
@TableName("warn_data")
public class WarnData{

	private String sn;

	private String content;

	private Integer time;

	@TableField("handle_state")
	private Integer handleState;

猜你喜欢

转载自blog.csdn.net/ty0903csdn/article/details/85166962