Spring boot에 H2 데이터베이스 연동하기

의존성 추가

build.gradle

// https://mvnrepository.com/artifact/com.h2database/h2
testImplementation group: 'com.h2database', name: 'h2', version: '2.1.214'

h2 연동

application-dev.properties

spring.h2.console.enabled:true
spring.h2.console.path=/h2_db
spring.datasource.url:jdbc:h2:file:~/{DB NAME};DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE
spring.datasource.driver-class-name:org.h2.Driver
spring.datasource.username:{USER NAME}
spring.datasource.password:{PASSWORD}

DB name, User name, password는 본인이 설정하면 된다.

답글 남기기