[SpringBoot] profile과 bean

1. spring boot에서 profile을 끌어가는 방법 : spring core

application.yaml에 등록된 profile 정보가 있다. spring은 여기서 local, dev, staging 등의 정보를 끌어간다. (어떻게?까지는 아직 내 레벨에선 이해하기 어려운 듯... ㅠ)

// application.yaml 파일

---
spring:
 config:
  activate:
   on-profile: local
 import: ~/configLocal.yml ...

spring.profiles.active = local

그리고 config.xml파일을 import하고 있는 걸 알 수 있음.

1-1. Profile이란?

Profile은 Bean의 그룹을 말한다. Spring은 다양한 profile을 지정할 수 있고, 필요한 bean을 불러와 사용한다.

@Profile("profile_name")

프로파일에는 논리적 연산자도 사용 가능하다.

  • ! : A logical "not" of the profile
  • & : A logical "and" of the profiles
  • | : A logical "or" of the profiles

https://colabear754.tistory.com/112

https://docs.spring.io/spring-boot/reference/features/profiles.html#features.profiles

https://velog.io/@tidavid1/Spring%EC%9D%98-Profile%EC%97%90-%EB%8C%80%ED%95%B4%EC%84%9C-%EC%95%8C%EC%95%84%EB%B3%B4%EC%9E%90

2. Naver pasta의 profile 지정 방법

파이프라인 생성 시에 차트 서비스를 작성한다. (chart config) 여기서 key, value 타입으로 지정이 가능하다.

  key value
set ...  
...  
springProfilesActive local
files .../.../....yaml