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

 

相關文章
相關標籤/搜索