在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结合一起用。