Skip to content

H2 임베디드 데이터베이스 설정

SyncBoot는 로컬 개발 및 단위 테스트 환경에서 경량 데이터베이스를 사용할 수 있도록 H2 In-Memory Database 설정을 지원합니다.


1. pom.xml 의존성 확인

xml
<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <scope>runtime</scope>
</dependency>

2. application-local.yml 설정 예시

yaml
spring:
  datasource:
    driver-class-name: org.h2.Driver
    url: jdbc:h2:mem:syncboot_db;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MySQL
    username: sa
    password:
  h2:
    console:
      enabled: true
      path: /h2-console
      settings:
        web-allow-others: true

3. H2 웹 콘솔 접속

  • URL: http://localhost:8080/h2-console
  • JDBC URL: jdbc:h2:mem:syncboot_db
  • User Name: sa
  • Password: (공백)