Today
-
Yesterday
-
Total
-
  • postgreSQL : Spring Boot 연동
    DB/PostgreSQL 2023. 12. 8. 00:01

    0. PostgreSQL에서 계정과 DB 생성

    spring boot 프로젝트와 연동할 postgreSQL 계정과 DB를 만들어두어야 한다.


    1. intelliJ 데이터베이스 연결

    1. intelliJ에서 데이터소스 - PostgreSQL 선택


    2. 드라이버 다운로드


    3. port번호, 사용자, 비밀번호, 데이터베이스 입력 후 연결테스트 후 확인!


    4. 생성 확인!

    테이블은 jpa가 만들어줄것임.

    😊


    2. spring boot 와 연결

    1. 의존성 추가

    runtimeOnly 'org.postgresql:postgresql'

    2. application.yml 설정

    spring.datasource 값을 입력해준다.

    spring:
      datasource:
        url: jdbc:postgresql://localhost:5432/board
        username: postgre
        password: sdfhaklsdhfkljhfjkfhhvbjhsgkuyilaweukasdkhjjkad
    

    driver-class-name 속성은

    spring boot가

    datasource.url의 값을 해석하여 알아서 설정해주기 때문에

    지정해주지 않아도 된다.


    3. 실행!

    spring boot 서비스를 실행시켜보면 테이블이 생성된 것과 postgreSQL dialect 로그가 출력된 것을 확인할 수 있다.

    'DB > PostgreSQL' 카테고리의 다른 글

    postgreSQL : 실행 명령어 몇가지  (0) 2023.12.08
    postgreSQL 설치 기록  (0) 2023.12.08

Designed by Tistory / Custom by 얼거스