PostgreSQL 설치
https://www.postgresql.org/download/macosx/ 를 통해서 PostgreSQL을 다운받습니다. 저는 16 버전(2024.08.01 기준)을 다운받았습니다.
다운받은 PostgreSQL을 설치 및 실행하고, Start 버튼을 클릭해 서버를 실행시킵니다.
pgAdmin 설치
https://www.pgadmin.org/download/pgadmin-4-macos/ 에서 pgAdmin4를 다운받습니다. 저는 8.10 버전(2024.08.01 기준)을 다운받았습니다.
pgAdmin을 실행시키고 Register -> Server 버튼을 클릭합니다.
General 탭에서 서버 이름을 작성해줍니다.
Connection 탭에서 Host name/address와 Username, Password를 작성해줍니다.
Save 버튼을 클릭해 서버를 생성합니다.
Create -> Database 버튼을 클릭합니다.
General 탭에서 데이터베이스 이름을 작성해줍니다.
Save 버튼을 클릭해 데이터베이스를 생성합니다.
Spring 연결
인텔리제이에서 프로젝트를 생성한 후, application.yml 파일에 아래 코드를 작성하고 서버를 실행시킵니다. 프로젝트 생성 방법은 하단 포스팅에 작성되어 있습니다.
spring:
datasource:
url: jdbc:postgresql://localhost:5432/{Database 이름}
username: {서버 생성 시 작성한 Username}
password: {서버 생성 시 작성한 Password}
driver-class-name: org.postgresql.Driver
https://jihyun-devstory.tistory.com/26
성공적으로 연결이 완료되면, 작성했던 엔티티가 Schemas - Tables에 등록됩니다.
아래 블로그를 참고하였습니다.
'⚙️ Backend' 카테고리의 다른 글
[Back-end] 단위 테스트 작성 방법(feat.TDD) (1) | 2023.11.09 |
---|---|
[Back-end] DTO vs VO vs Entity (0) | 2023.11.09 |