Mybatis默认不识别驼峰命名

mybatis驼峰式命名规则自动转换:

使用前提:数据库表设计按照规范“字段名中各单词使用下划线"_"划分”;
使用好处:省去mapper.xml文件中繁琐编写表字段列表与表实体类属性的映射关系,即resultMap。
1、方式一
  直接application.yml文件中配置开启
#mybatis配置
mybatis:
typeAliasesPackage: com.example.mybaitsxml.dao.entity
mapperLocations: classpath:mapper/*.xml
configuration:
map-underscore-to-camel-case: true

2、方式二
  mybatis-config.xml文件中配置开启,application.yml文件指定配置文件。
application.yml文件:
#mybatis配置
mybatis:
typeAliasesPackage: com.example.mybaitsxml.dao.entity
mapperLocations: classpath:mapper/*.xml
configLocation: classpath:/mybatis-config.xml
mybatis-config.xml文件:

你可能感兴趣的:(Mybatis默认不识别驼峰命名)