mybatis驼峰命名怎么配置

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

在mybatis-config.xml或者application.properties中配置:

<settings>
    <setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>

在SpringBoot中配置application.properties文件:

mybatis.configuration.map-underscore-to-camel-case=true

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

阅读剩余
THE END