1. 程式人生 > >【MyBatis】SpringBoot開啟駝峰轉換功能

【MyBatis】SpringBoot開啟駝峰轉換功能

      資料庫用的是postgresql,file表中有個時間欄位create_date(沒有采用駝峰法),在實體類中是createDate(採用駝峰法)。

       當我查詢資料時,發現createDate一直是null

      於是猜想是不是因為實體與表的映射出了問題,因此在配置檔案application.yml中開啟mybatis的駝峰功能嘗試,果然就有時間了。

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

      其實針對這個報錯,採用在xml檔案中寫一個resultMap也是可以解決的,只是顯得有些繁瑣。