[Spring Boot] application.yml 정리

[Spring Boot] application.yml 정리

Last Updated: 2025년 07월 05일

개인적으로 만든 사이트의 application.yml 최종 설정 내용. ${SERVER_PORT} .. 등등은 반드시 .env 파일에 저장.

##############################################################
# SERVER
server:
  port: ${SERVER_PORT}
  tomcat:
    max-threads: 200                    # 최대 스레드 수 (서버의 CPU 코어 수 및 메모리에 맞춰 조정)
    min-spare-threads: 10           # 최소 유휴 스레드 수 (처리할 수 있는 스레드 수가 부족할 경우 증가)
    max-connections: 500            # 최대 연결 수 (동시 연결 수가 많을 경우 성능에 영향을 미침)
    connection-timeout: 20000  # 연결 타임아웃 (20초로 설정)

##############################################################
spring:
  codec:
    max-data-buffer-size: 1048576 # 1MB (1024 * 1024 bytes)
  jvm:
    heap-size: -Xms2g -Xmx2g  # 최소 2GB, 최대 2GB 힙 메모리 할당 (필요에 따라 조정)
  application:
    name: gongmuin
  profiles:
    active: local # 운영 시 'prod'로 변경
    include:
      - datasource
      - oauth
      - actuator
  config:
    import: optional:file:.env[.properties] # .env import

  devtools:
    restart.enabled: true
    livereload.enabled: false

  cache:
    caffeine:
      spec: expireAfterWrite=5m,maximumSize=1000 # 5분 TTL, 최대 1000개 엔트리

  thymeleaf:
    cache: false # 운영 시 true로 변경

  data:
    redis:
      host: ${REDIS_HOST}
      port: ${REDIS_PORT}
      password:
    web:
      pageable:
        one-indexed-parameters: true

  mail:
    host: smtp.naver.com
    port: 465
    username: ${MAIL_USERNAME}
    password: ${MAIL_PASSWORD}
    properties:
      mail.smtp:
        auth: true
        ssl.enable: true
        ssl.trust: smtp.naver.com
        starttls.enable: true
        starttls.required: true
        connectiontimeout: 5000
        timeout: 5000
        writetimeout: 5000
    auth-code-expiration-millis: 180000  # 3분

  servlet:
    multipart:
      enabled: true
      location: D:/temp/upload-files
      max-file-size: 10MB
      max-request-size: 10MB

  # 정적 리소스 캐싱 설정
  web:
    resources:
      cache:
        cachecontrol:
          max-age: 3600
          must-revalidate: true

  # Virtual Threads 활성화
  threads:
    virtual:
      enabled: true # Java 21 Virtual Thread (적용 상황 따라 조정)

  task:
    execution:
      pool:
        core-size: 10              # 기본 스레드 수 (가상 스레드의 기본 동작이므로 대부분 설정하지 않아도 됩니다)
        max-size: 50              # 최대 스레드 수 (필요시 설정)
        queue-capacity: 100 # 큐가 찼을 때 새 스레드를 만듬
    scheduling:
      pool:
        size: 10                         # 스케줄러용 기본 스레드 풀 크기

################################################################
# AWS S3
cloud:
  aws:
    credentials:
      access-key: AWS_S3_ACCESS_KEY # 엑세스 키 ID (AWS S3에서 발급 받은 키
      secret-key: AWS_S3_SECRET_KEY # 비밀 엑세스 키 (AWS S3에서 발급 받은 키)
    region:
      static: ap-northeast-2
    s3:
      bucket: narrator.kr

##############################################################
# 외부 연결 주소
direct:
  sign-up: http://localhost:${SERVER_PORT}
  home: http://localhost:${SERVER_PORT}

##############################################################
# JWT
security:
  jwt:
    secret-key: ${JWT_KEY}
    expiration:
      access: 3600000        # Access Token 유효 시간 (ms), 1분 (60 * 1 * 1000), 5시간(60 * 60 * 5 * 1000)
      refresh: 3600000 # Refresh Token 유효 시간 (ms), 1시간 (60 * 60 * 1 * 1000), 7일(60 * 60 * 24 * 7 * 1000)

##############################################################
# OAuth (예: GitHub)
auth:
  github:
    client-id: ${GITHUB_CLIENT_ID}
    client-secret: ${GITHUB_CLIENT_SECRET}
    redirect-uri: ${GITHUB_REDIRECT_URI}
    client-uri: ${GITHUB_CLIENT_URI}
    # base-url: http://localhost:${SERVER_PORT} (필요 시 활성화)

################################################################
# 외부 Open API Keys
datagokr-api:
  key: ${DATAGOKR_KEY}

open-api:
  key: ${OPENAPI_KEY}

whois:
  api-key: ${WHOIS_KEY}

youtube:
  secret-key: ${GOOGLE_API_KEY}

################################################################
# Logging Aspect Settings
logging.aspect.log-args: true   # 요청 인자 로깅 활성화 (기본값 true)
logging.aspect.log-responses: true # 응답 값 로깅 활성화 (기본값 true)

################################################################
# 업로드 공통
file:
  base-dir: ./upload/          # 실제 저장 위치
  base-url: /uploadPath  # 정적 경로 prefix
################################################################
upbit:
  base-url: https://api.upbit.com/v1
################################################################
springdoc:
  swagger-ui:
    path: /swagger-ui.html
    display-request-duration: true
    try-it-out-enabled: true
    persist-authorization: true
    doc-expansion: none   # Lazy 로딩으로 초기 렌더링 성능 향상
    filter: true          # API 검색 필터 활성화
    tags-sorter: alpha
    operations-sorter: alpha
################################################################

################################################################

################################################################

You may also like