mybatis驼峰命名怎么配置

622
2024/1/24 16:12:28
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在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。

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: mybatis更新字段为空怎么解决