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

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

但是java中一般使用驼峰命名 
数据库表列:user_name 

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

 

 实体类属性:userName

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

 

 Mapper.xml中的userName

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

 

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

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

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

 

相关文章:

  • 2022-12-23
  • 2021-07-13
  • 2021-04-20
  • 2022-01-02
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-24
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2021-08-14
  • 2021-06-13
相关资源
相似解决方案