mybatis

mybatis驼峰命名怎么配置

小亿
286
2024-02-22 16:12:28
栏目: 编程语言

在MyBatis中配置驼峰命名可以通过在配置文件中添加以下设置实现:

  1. 在mybatis-config.xml或者application.properties中配置:
<settings>
    <setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>
  1. 在SpringBoot中配置application.properties文件:
mybatis.configuration.map-underscore-to-camel-case=true

这样配置之后,MyBatis会自动将数据库中的下划线命名转换为驼峰命名,例如数据库字段名为user_name,会被映射为Java类属性名为userName。

0
看了该问题的人还看了