mybatis 解决下划线映射

发布时间:2020-07-02 17:21:39

mybatis默认是属性名和数据库字段名一一对应的,即
数据库表列:user_name
实体类属性:user_name

但是java中一般使用驼峰命名
数据库表列:user_name
实体类属性:userName

在Springboot中,可以通过设置map-underscore-to-camel-case属性为true来开启驼峰功能。
application.yml中:

    mybatis:
      configuration:
        map-underscore-to-camel-case: true


application.properties中:

mybatis.configuration.map-underscore-to-camel-case:=true


Card image cap
APP STORE
Card image cap
应用宝
Card image cap
小米
Card image cap
华为