[MyBatis] DB snake_case 를 camelCase 로 자동 변환하기 (Spring Boot)


db 컬럼은 보통 snake case로, Java 객체는 주로 camel case 로 사용하는데

서로 이름을 맞춰주지않는다면 가져올수가 없다.

그래서 쿼리문 alias 를 이용하여 맞춰줄수도 있지만 설정한줄을 통해 가능하다

application.yaml 또는 application.properties 에 다음과 같은 설정을 넣어주면 된다.

.yaml

mybatis:

  configuration:

    map-underscore-to-camel-case: true

.properties

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

Leave a Comment