JVM/Spring
[Spring] h2 설정
Hyo Kim
2023. 1. 29. 16:47
728x90
반응형
OS
M1 MAX
macOS Ventura 13.2
PROJECT
java - 11
kotlin - 1.6.21
spring - 2.7.8
build.gradle.kts
dependencies {
...
runtimeOnly("com.h2database:h2")
}
application.yml
spring:
h2:
console:
enabled: true
path: /h2-console
datasource:
url: jdbc:h2:mem:test
username: sa
password:
driverClassName: org.h2.Driver
platform: h2
접근 url - http://localhost:8080/h2-console
에러사항
원인
데이터베이스가 존재하지 않아서 발생되는 문제입니다.
H2:1.4.198 버전부터는 보안상의 이유로 데이터베이스 자동생성을 막아두었습니다.
터미널을 통해 h2를 설치하여 수동으로 데이터베이스를 생성해줍니다.
# h2 설치
$ brew install h2
# h2 web console running - 해당 주소로 접근
$ h2 -web
Web Console server running at http://localhost:8082?key=cb6e18688aedfd770688bcb1278337893504c2834d06e6023e6d3c25346cb1a8 (only local connections)
728x90
반응형