250x250
반응형
arkhyeon
arkhyeon
arkhyeon
전체 방문자
오늘
어제
  • 분류 전체보기 (88)
    • Spring (5)
    • Java (4)
    • React (25)
      • TypeScript (6)
      • JavaScript (1)
      • Jest (9)
    • NEXT (8)
    • SQL (1)
    • React native (1)
    • CSS (3)
    • Web (1)
    • Git (3)
    • ETC (6)
    • 빅데이터DB (8)
    • Docker (4)
    • Tool (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • javasciprt websocket
  • react typescript
  • Spring WebSocket
  • websocket
  • react usetransition
  • kudu
  • react jest
  • HIVE
  • jest
  • docker tomcat
  • WSS
  • react loading
  • javascript wss
  • react spring websocket
  • usetransition
  • websocket server
  • react19
  • node WebSocket
  • react
  • react websocket

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
arkhyeon

arkhyeon

Spring

프론트엔드 개발자 API 서버 열기 Spring Java Redis PostgreSQL

2024. 3. 12. 11:25
728x90
반응형

application-dev.yml

해당 파일에서 PostgreSQL, Redis를 사용하는 것으로 파악했다.

spring:
  h2:
    console:
      enabled: true
      settings:
        web-allow-others: true
      path: /h2-console
  jpa:
    hibernate:
      ddl-auto: create-drop
    properties:
      hibernate:
        show_sql: true
        format_sql: true
        use_sql_comments: true
        default_batch_fetch_size: 100
    database-platform: org.hibernate.dialect.PostgreSQLDialect
  logging.level:
    org.hibernate.SQL: debug
  datasource:
    driver-class-name: org.postgresql.Driver
    url: <POSTGRESQL URL> localhost
    username: <POSTGRESQL USERNAME> postgresql
    password: <POSTGRESQL PWD> postgresql
  data:
    redis:
      host: <REDIS HOST> localhost
      port: <REDIS PORT> 6379
  servlet:
    multipart:
      max-file-size: 10MB
      max-request-size: 10MB
server:
  port: 8787
file:
  path: src/main/resources/static/image/
jwt:
  secret:
    key: <JWT SECRET KEY>

DB 연결

 

Install PostgreSQL

Summary: in this tutorial, you will step by step learn how to install PostgreSQL on your local system. Neon Postgres – Fully Automated, Generous Free Tier, Instant DBs, Autoscaling, Git-like Branching - Start Free Sponsored PostgreSQL was developed for U

www.postgresqltutorial.com

PostgreSQL 설치 후 데이터베이스 툴에서 로컬 접속 테스트 후 datasource.url, datasource.password, datasource.username 작성

Redis 연결 (Redis Window / Docker)

Redis Window

https://github.com/microsoftarchive/redis/releases - Redis-x64-3.0.504.msi 설치

redis-server.exe - redis 실행 / redis-cli.exe - redis 명령어 실행

redis 실행 후 Spring Application 실행

Docker

 

Docker Desktop: The #1 Containerization Tool for Developers | Docker

Docker Desktop is collaborative containerization software for developers. Get started and download Docker Desktop today on Mac, Windows, or Linux.

www.docker.com

도커 편의성을 위해 docker desktop 설치 후 redis images를 pull 받아줬다.

도커 컨테이너 실행 (Redis)

# docker image pull redis //docker desktop 없이 진행
docker run --name myredis -p 6379:6379 -v C:\\home\\docker\\redis:/data -d redis:latest redis-server --appendonly yes
  • --name myredis
    컨테이너 이름을 myredis 지정
  • p 6379:6379
    호스트의 6379 포트를 컨테이너의 6379 포트에 매핑하여 Redis 서버가 호스트 시스템에서 접근 가능
  • -v C:\home\docker\redis:/data
    호스트의 C:\home\docker\redis 폴더를 컨테이너의 /data 폴더에 마운트하여 Redis 데이터를 호스트에 저장
  • -d
    컨테이너를 백그라운드에서 실행
  • redis:latest
    사용할 Docker 이미지를 지정 생성한 도커 이미지 이름과 동일하게 작성
  • redis-server --appendonly yes
    컨테이너 내에서 실행할 명령어로 Redis 서버 시작 후 -appendonly yes 옵션으로 데이터를 디스크에 저장하도록 설정

Spring Start Setting

application-dev.yml 설정 파일로 실행하기 위해 Active profiles에 dev 작성 후 실행하면 정상 작동

728x90
반응형

'Spring' 카테고리의 다른 글

Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.1.  (0) 2024.03.05
Spring WebSocket Server - React  (1) 2023.10.31
Maven & Gradle  (0) 2022.06.16
Maven & Gradle  (0) 2022.05.24
    'Spring' 카테고리의 다른 글
    • Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.1.
    • Spring WebSocket Server - React
    • Maven & Gradle
    • Maven & Gradle
    arkhyeon
    arkhyeon

    티스토리툴바