首页 > 其他 > 详细

驼峰命名法

时间:2019-10-14 15:26:33      阅读:86      评论:0      收藏:0      [点我收藏+]

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

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

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

mybatis-plus:
  configuration:
    # 配置返回数据库(column下划线命名&&返回java实体是驼峰命名),自动匹配无需as(没开启这个,SQL需要写as: select user_id as userId)
    map-underscore-to-camel-case: true

application.properties中:

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

欲买桂花同载酒,终不似,少年游

驼峰命名法

原文:https://www.cnblogs.com/antonChen/p/11671586.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!