在MyBatis中配置驼峰命名可以通过在配置文件中添加以下设置实现: 在mybatis-config.xml或者application.properties中配置: <settings> <
在MyBatis中配置驼峰命名可以通过在配置文件中添加以下设置实现:
- 在mybatis-config.xml或者application.properties中配置:
<settings>
<settingname="mapUnderscoreToCamelCase"value="true"/>
</settings>
mybatis.configuration.map-underscore-to-camel-case=true
这样配置之后,MyBatis会自动将数据库中的下划线命名转换为驼峰命名,例如数据库字段名为user_name,会被映射为Java类属性名为userName。
版权声明
本文仅代表作者观点,不代表博信信息网立场。