首页 > 其他 > 详细

Mybatis开启驼峰命名,作用

时间:2020-01-09 14:18:11      阅读:168      评论:0      收藏:0      [点我收藏+]

在applocation.yml文件中,

mybatis:
configuration:
#开启自动下划线格式转驼峰格式
map-underscore-to-camel-case: true
config-locations: classpath:/mybatisConfig.xml
mapper-locations: classpath:mybatis/**/*.xml
type-aliases-package: com.lvjing.domain

configuration:
#开启自动下划线格式转驼峰格式
map-underscore-to-camel-case: true
     #下面这个优先级更高
      mapUnderscoreToCamelCase: true


也可以写在mybatisConfig.xml中
<configuration>
    <!--开启驼峰命名规则自动转换-->
    <settings>
    <setting name="mapUnderscoreToCamelCase" value="true" />
    </settings>
</configuration>



作用:
可以省写resultMap

不开启:
<resultMap id="BaseResultMap" type="com.lvjing.domain.housekeeping.WxCleaner">
<result column="id" property="id"/>
<result column="cleaner_name" property="cleanerName"/>
<result column="cleaner_mobile" property="cleanerMobile"/>
<result column="current_order" property="currentOrder"/>
<result column="password" property="password"/>
<result column="remark" property="remark"/>
<result column="create_time" property="createTime"/>
</resultMap>

开启:(只需要指定对应pojo实体类)
<resultMap id="BaseResultMap" type="com.lvjing.domain.housekeeping.WxCleaner">
</resultMap>



但是映射不同字段的话,需要配合resultMap
仅是省力工具,具体开发过程应该与resultMap结合一起用。

Mybatis开启驼峰命名,作用

原文:https://www.cnblogs.com/zhuangyao/p/12171090.html

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