Spring Profile 설정하기

킹다·2021년 8월 9일
0

서비스를 운영할 때 로컬환경과 실제 운영환경의 세팅이 다르고 그 세팅을 바꾸는게 번거롭게 느껴져서 Spring Profile 설정에 대해 알아봤다..

1. Spring Profile 이 뭐지?

보통 기본적으로 다른건 아마 DB환경일 것이다. 어떠한 특정 설정값을 다르게 하고싶을 때 사용한다. 그래서 기본적으로 배포환경이나 테스트 환경, 등 환경 세팅 값이 다를 때 사용한다.

2. Profile을 써보자

application.yml

spring:
  profiles:
    active: local

#local
---
server:
  port: 8080
  ~
spring:
  profiles: local
---

#dev
server:
  port:8080
  ~
spring:
  profiles: dev
---

#prod
server:
  port: 8080
  ~
spring:
  profiles: prod

이런 식으로 환경을 분리를 해주면 된다.

profile
스프링마스터가 되고싶은 사람…

0개의 댓글