H2 Database 사용하기


1. 의존성 추가


dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    runtimeOnly 'com.h2database:h2'
}

2. applicatoin.yml 예시

**spring:
  datasource:
    url: jdbc:h2:mem:testdb
    driver-class-name: org.h2.Driver
    username: sa
    password:
  h2:
    console:
      enabled: true
      path: /h2-console
  jpa:
    hibernate:
      ddl-auto: update
    database-platform: org.hibernate.dialect.H2Dialect**

3. 애플리케이션 실행

참고자료


스프링 부트(Spring Boot) - 5분 안에 H2 Database와 JPA 연동해보기