SpringBoot Mybatis 的驼峰命名 开启驼峰命名的方法
第一种方式:
在SpringBoot的application配置文件中进行设置,这里是properties的配置,配置的Demo如下:
mybatis.configuration.mapUnderscoreToCamelCase=true
或
mybatis.configuration.map-underscore-to-camel-case=true
另外两种
链接: SpringBoot Mybatis 的驼峰命名 开启驼峰命名的方法.
SpringBoot 中开启 驼峰命名 就可以 Mybatis 的mapper中返回结果用 resultType (这个的不一样(数据库 user_name) 实体类(userName))
(自己理解 底层 _n自动变成N)
如果不开启 驼峰命名 数据库中的列名 和 代码中实体类的变量不一样时(这个的不一样(数据库 user_name) 实体类(userName))就必须用resultMap