【详解】springboot主配置文件配置,mybatis配置项mybatis.configuration.map-underscore-to-camel-case=true/false

      在springboot配置的时候,一般添加上:mybatis配置项 mybatis.configuration.map-underscore-to-camel-case=true/false,原因如下

      当我们在MySQL定义表的字段的时候,有的字段定义成比如user_name,user_password的形式,但是在我们Java语言创建实体类的时候遵循实体类的属性是驼峰原则,一般实体类属性写成userName,userPassword的形式。使用mybatis框架的时候,mybatis会帮我们检查数据库的字段和实体类的属性名是否一致,这个配置就是将带有下划线的表字段映射为驼峰格式的实体类属性:user_Id映射到userId。如果不使用这个配置,需要使用as关键字起别名,代码量会大一点。所以还是建议使用这个配置简化开发。

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

猜你喜欢

转载自blog.csdn.net/Sunshineoe/article/details/114652742