4.2. JPA 연동하기

데이터베이스와는 datasource를 통해 연동할 준비가 되었지만, 아직 JPA를 사용할 준비는 되지 않은 상태입니다. 하나씩 따라해 보겠습니다.


먼저 build.gradle에 JPA 라이브러리가 설정되어 있는지 확인해 주세요.
build.gradle

dependencies {  
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'  
... 생략 ...  
}  

다음으로는 스프링 부트에게 JPA 설정 정보를 알려줍니다.

src/main/resources > application.properties

Copyspring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect  
spring.jpa.properties.hibernate.format_sql=true  
spring.jpa.properties.hibernate.show_sql=true  
spring.jpa.hibernate.ddl-auto=update