반응형

환경 : 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

 

 

반응형

'Java' 카테고리의 다른 글

[SpringBoot] Gradle 변수 Property 활용  (0) 2022.05.30
[MyBatis] List 형식 멤버 변수 조회  (0) 2021.02.12
[Spring] Web Cache 적용  (0) 2020.12.19
[SpringBoot] H2 연동  (0) 2020.07.21
[Spring] App 구동 후 자동 작업 실행  (0) 2020.02.23

+ Recent posts