Springboot中MyBatis 自动转换 map-underscore-to-camel-case

在SpringBoot中使用MyBatis 都是经过配置完成的java

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

可是java中通常使用驼峰命名 
数据库表列:user_name mybatis

 

 实体类属性:userNameapp

 

 Mapper.xml中的userNamespa

 

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

mybatis:
  mapper-locations: classpath:mapping/*Mapper.xml
  type-aliases-package: com.herbert.demo.entity
  configuration:
    map-underscore-to-camel-case: true
    cache-enabled: false

 

相关文章
相关标签/搜索