• Home
  • About
    • Junseok photo

      Junseok

      개발자 블로그

    • Learn More
    • Facebook
    • Instagram
    • Github
  • Posts
    • All Posts
    • All Tags
  • Java
    • java-basic
    • java-solid
    • java-pattern
    • java-logging
  • Javascript
  • Angular
  • spring
    • spring-framework
    • spring-boot
    • spring-test
  • server
    • jeus
    • webtob
    • tomcat
  • test
    • junit
    • assertj
    • hamcrest
    • dbunit
    • spring
  • docker
  • unix
  • maven
  • db
  • network
  • eclipse
  • intellij
  • microservices
  • etc

H2 Database

02 Nov 2019

Reading time ~1 minute

H2 Database 란?

  • 오픈 소스 데이터베이스이며 Java로 작성되었습니다.
  • 매우 빠르고 매우 작은 크기입니다.
  • 주로 메모리 내 데이터베이스로 사용됩니다.
    데이터를 메모리에 저장하고 디스크에 데이터를 유지하지 않습니다.
  • 데이터를 유지해야하는 경우 디스크에 데이터를 유지할 수도 있습니다.

  • H2 데이터베이스는 프로덕션 환경에 권장되지 않습니다.
  • 간단한 데이터베이스가 필요한 테스트 프로젝트에 이상적입니다.

  • 일반적으로 인메모리 데이터베이스로 사용됩니다.

H2 Database의 주요 기능

  • 매우 빠른 오픈 소스 JDBC API
  • 임베디드 및 서버 모드; 인 메모리 데이터베이스
  • 브라우저 기반 콘솔 애플리케이션
  • 작은 설치 공간 : 약 2MB의 jar 파일 크기

출처:h2database.com

Spring boot 에 H2Database 적용하기

  1. Dependency 추가

    pom.xml

    ~~~xml

com.h2database h2 runtime

2. 접속정보 설정  
#### application.properties
~~~properties
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=pass
  1. 그 외 설정

    application.properties

    spring.h2.console.enabled=true
    spring.h2.console.path=/h2
    
  • spring.h2.console.enabled
    browser console을 사용할 것인가

  • spring.h2.console.path
    browser console 에 접근하기 위한 path(경로) 기본 경로 : http://localhost/h2-console



H2 Share Tweet +1