【MyBatis】SpringBoot开启驼峰转换功能

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Mr_EvanChen/article/details/83829967

      数据库用的是postgresql,file表中有个时间字段create_date(没有采用驼峰法),在实体类中是createDate(采用驼峰法)。

       当我查询数据时,发现createDate一直是null

      于是猜想是不是因为实体与表的映射出了问题,因此在配置文件application.yml中开启mybatis的驼峰功能尝试,果然就有时间了。

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

      其实针对这个报错,采用在xml文件中写一个resultMap也是可以解决的,只是显得有些繁琐。

猜你喜欢

转载自blog.csdn.net/Mr_EvanChen/article/details/83829967
今日推荐