Springboot中MyBatis resultType 开启自动映射

  • Post author:
  • Post category:其他


原文连接:

https://blog.csdn.net/lyp1245387976/article/details/108194501

通常数据库列使用大写字母组成的单词命名,单词间用下划线分隔;

而 Java 属性一般遵循驼峰命名法约定

为了在这两种命名方式之间启用自动映射,需要将 mapUnderscoreToCamelCase 设置为 true

但SpringBoot没有mybatis-config.xml 文件

可以通过设置application.yml文件来开启自动映射

map-underscore-to-camel-case 设置为 true

mybatis:
  configuration:
    map-underscore-to-camel-case: true