Spring boot에 PostgreSQL DB 연결

하쮸·2024년 10월 22일
0

1. Spring boot에 PostgreSQL 연결

1-1. PostgreSQL 홈페이지에서 DBMS 다운로드

1-2. DB 생성.

1-3. PostgreSQL Driver 추가.

  • build.gradel에 가서 라이브러리 추가
    • dependenciesruntimeOnly 'org.postgresql:postgresql' 작성.

  • 우측 Gradle -> runtimeClasspath -> postgresql driver가 추가된걸 확인 할 수 있음.

1-3-1. 참고 - Dependencies 코드 확인하는 방법.

  • 우측 Add dependencies... 클릭해서 추가.

  • 이렇게 3개를 추가했을 때 build.grade에 어떤 코드가 입력되는 지 확인하고 싶을때.
    • 하단에 EXPLORE 클릭.

1-4. DB 연동 설정.

  • application.properties에서 설정.
spring.datasource.url=jdbc:postgresql://localhost:5432/(db 이름)
spring.datasource.username=사용자명
spring.datasource.password=패스워드
profile
Every cloud has a silver lining.

0개의 댓글