728x90
반응형

환경 : SpringBoot 2.7, Intellij

목표 : profile 환경 변수를 기준으로 서로 다른 Property 를 적용

 

1. spring.config.activate.on-profile 을 사용하여 적용될 profile 을 명시

 

application.yml

default:
  string: default

custom:
  string: noProfile

application-custom.yml

custom:
  string: custom

spring:
  config:
    activate:
      on-profile: custom

application-local.yml

spring:
  config:
    activate:
      on-profile: local

 

 

 

2. 적용할 profile 환경 변수 설정

 

Edit Configurations -> Active profiles 설정

 

 

 

3. 결과

 

3.1) profile 설정 X

default.string = default

custm.string = noProfile

 

3.2) profile : local

default.string = default

custm.string = noProfile

 

3.3) profile : custom

default.string = default

custm.string = custom

 

 

728x90
반응형

+ Recent posts