inblog logo
|
keepgoing
    SpringBoot

    [Springboot] 4 h2 데이터베이스

    김호정's avatar
    김호정
    Aug 14, 2024
    [Springboot] 4 h2 데이터베이스
    Contents
    1. 라이브러리2. application 설정하기3. DB 접속해보기
     
    💡
    h2는 인메모리 데이터베이스 스프링에는 h2가 내장되어있다. 내장되어있어서 사용하기 편리하기 때문에 테스트할 때 많이 사용한다. 테스트 다 끝나면 실제 데이터 베이스로 바꿔끼우면 된다. 데이터베이스는 메모리에 있는걸 하드디스크에 저장하는데? 이게 커밋이다.(commit) h2는 인메모리 어쩌고 이기 때문에 커밋 안됨 그래도 H2 자체만의 장점이 있다. 협업 시 모두가 같은 조건으로 코딩을 할 수 있다고 한다
     
     

    1. 라이브러리

    runtimeOnly 'com.h2database:h2'
     

    2. application 설정하기

    #url은 내가 맘대로 바꿔서 적을 수 있는게 아니다. 이대로 적기
    # h2 아이디 비밀번호 설정 (비밀번호 생략) spring.datasource.driver-class-name=org.h2.Driver spring.datasource.url=jdbc:h2:mem:test spring.datasource.username=sa
     

    3. DB 접속해보기

    localhost:8080/h2-console 로 접속하기
    notion image
    Share article
    Contents
    1. 라이브러리2. application 설정하기3. DB 접속해보기

    keepgoing

    RSS·Powered by Inblog