mybatis中mapUnderscoreToCamelCase自动驼峰命名转换
2017-11-07 17:11
1306 查看
ssm项目中在mybatis配置文件中添加以下配置,可以将数据库中user_name转化成userName与实体类属性对应,如果数据库使用如user_name的命名方式,实体类采用驼峰命名。配置后无需写resultMapper将数据库字段和实体类属性对应
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true" />
</settings>
</configuration>
在spring boot项目中没有mybatis.xml文件,配置文件application.properties中,加入配置项:
1 mybatis.configuration.mapUnderscoreToCamelCase=true
2 或
3 mybatis.configuration.map-underscore-to-camel-case=true设为true表示开启驼峰转换。经过试验,两种配置方法都可以。但如果同时配置,前者mybatis.configuration.mapUnderscoreToCamelCase的优先级更高
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true" />
</settings>
</configuration>
在spring boot项目中没有mybatis.xml文件,配置文件application.properties中,加入配置项:
1 mybatis.configuration.mapUnderscoreToCamelCase=true
2 或
3 mybatis.configuration.map-underscore-to-camel-case=true设为true表示开启驼峰转换。经过试验,两种配置方法都可以。但如果同时配置,前者mybatis.configuration.mapUnderscoreToCamelCase的优先级更高
相关文章推荐
- Mybatis 之mapUnderscoreToCamelCase
- Mybatis配置文件中的mapUnderscoreToCamelCase属性
- mybatis-spring 启用 mapUnderscoreToCamelCase xml 配置
- mybatis属性callSettersOnNulls,mapUnderscoreToCamelCase设置
- JSONModel命名中的驼峰(CamelCase)与下划线 (UnderscoreCase)
- 驼峰命名法(CamelCase)和下划线命名法(UnderScoreCase)之间的转换
- Mybatis 之mapUnderscoreToCamelCase
- mybatis中mapUnderscoreToCamelCase的使用
- mybatis中mapUnderscoreToCamelCase的使用
- 驼峰命名法(CamelCase)和下划线命名法(UnderScoreCase)字符之间的转换
- spring boot 整合mybatis如何开启开启驼峰命名转换
- mybatis开启字段自动映射为java驼峰命名规则
- mybatis数据库命名与驼峰命名转换-csdn
- 驼峰命名法(CamelCase)和下划线风格(UnderScoreCase)字符串之间的转换工具类
- Mybatis开启数据库字段自动映射为驼峰命名
- mybatis开启数据库字段自动映射为java驼峰命名规则
- mybatis开启数据库字段自动映射为java驼峰命名规则
- SpringBoot中mybatis配置自动转换驼峰标识没有生效
- mybatis开启数据库字段自动映射为java驼峰命名规则
- jQuery源码中的驼峰命名jQuery.camelCase