Develop/Spring Boot

[Spring boot] application.yml 설정

roalwh 2023. 10. 24. 17:02

application.yml 설정

# https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#application-properties.core.spring.profiles.default

#application.yml 설정
#사용할 yml파일 이름 application-{이름}.yml -> 파일로 구분시
spring:
  profiles:
    active: dev    #프로파일 값없으면 시스템 기본값으로 처리
    include:     # 반드시 실행 되어야 할 프로파일

  servlet:
    #파일 업로드 시 용량 설정
    #기본 용량이 많이 적은편..
    multipart:
      max-file-size: 50MB
      max-request-size: 100MB

  security:
    user: # spring security 기본 아이디와 암호
      name: user
      password: 1234

  jpa:
    properties:
      hibernate:
        default_batch_fetch_size: 200
        format_sql: true  # sql문을 보기 편하게 해준다.
        use_sql_comments: true


---
# application-dev
#profile 이름 설정
spring:
  config:
    activate:
      on-profile: dev

  h2:
    console:
      enabled: true  # H2 Console을 사용할지 여부 (H2 Console은 H2 Database를 UI로 제공해주는 기능)
      path: /h2-console  # H2 Console의 Path
    # Database Setting Info (Database를 H2로 사용하기 위해 H2연결 정보 입력)
    datasource:
      driver-class-name: org.h2.Driver  # Database를 H2로 사용하겠다.
      url: jdbc:h2:~/test  # H2 접속 정보
      username: sa  # H2 접속 시 입력할 username 정보 (원하는 것으로 입력)
      password:  # H2 접속 시 입력할 password 정보 (원하는 것으로 입력)

  jpa:
    show-sql: true
    defer-datasource-initialization: true # data.sql 사용을 위해서 필수적으로 등록
    generate-ddl: false   # true, false // false 가 기본
    hibernate:
       ddl-auto: update
       # create(처음생성시,테스트), create-drop, update(db가 확정되었을 때,수정단계일때), validate, none(최종)

  sql:
    init:
      mode: never
      # always: embeded db가 아닌 외부 db 사용시 spring boot를 실행할때 마다 data.sql schema.sql import.sql을 항상 실행
      # never: data.sql schema.sql import.sql을 실행하지 않음
      encoding: utf-8

#아파치 포트 설정
server :
  port : 9000


---
#application-prod
spring:
  config:
    activate:
      on-profile: prod

  datasource:
    url: jdbc:mariadb://
    driver-class-name: org.mariadb.jdbc.Driver
    username:
    password:

---


'Develop > Spring Boot' 카테고리의 다른 글

DisconnectableInputStream source reader 에러  (0) 2023.11.23
디자인 패턴  (1) 2023.11.17
gitignore 파일  (0) 2023.10.23
.gitignore 작성하기  (0) 2023.10.23
Spring initializr 설정 하기  (0) 2023.10.23