JPA
[JPA] Gradle - ddl auto 설정
봉주니
2022. 2. 16. 16:25
JPA란?
JPA(Java Persistence API)
설정
build.gradle
dependencies{
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
}
application.yml
spring:
datasource:
url: jdbc:mysql://(host):(port)/(dbname)
username: (username)
password: (password)
jpa:
hibernate:
ddl-auto: create-drop
show-sql: true
- create
- 기존 Table Drop + 생성
- create-drop
- create후 종료시 drop까지 실행
- update
- 변경된 내용만 수정한다. 이건 JPA스팩에는 없고 hibernate에만 있는 설정 이다.
- validate
- 기존 DB Table정보와 비교해서 차이가 있다면 경고하고 애플리케이션을 실행 하지 않는다. 이건 JPA스팩에는 없고 hibernate에만 있는 설정 이다.
- none
- 설정이 없거나 유효하지 않은 값을 설정하면 기능을 사용하지 않게된다.
- show-sql
- console에 JPA 실행 SQL Log 유무. true/false
반응형