Springboot中MyBatis 自动转换 map-underscore-to-camel-case
在SpringBoot中使用MyBatis 都是通过配置完成的
mybatis默认是属性名和数据库字段名一一对应的,即
数据库表列:user_name
实体类属性:user_name
但是java中一般使用驼峰命名
数据库表列:user_name
实体类属性:userName
Mapper.xml中的userName
在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
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步