-
환경변수 관리하기 - mvn, spring with profilespring 2021. 3. 24. 13:33728x90반응형
1. maven profile 활용 1
가. 설정
나. 활용
ㄱ. 로컬
$ mvn -Plocal install
build-local.properties
META-INF/config.xml
ㄴ. 스테이징
$ mvn -Pstaging install
build-staging.properties
META-INF/config.xml
ㄷ. 운영서버1
$ mvn -Pprod1 install
build-prod1.properties
META-INF/config.xml
다. maven profile 장단점
ㄱ. 장점
- 스프링 애플리케이션에서는 단순한 설정형태 유지
- 이클립스 및 인텔리J 등 IDE플러그인에서 프로파일 지원 (프로파일을 변경하면 자동으로 빌드 된다거나..)
ㄴ. 단점
- 프로파일 단위로만 properties 생성하기 때문에 중복환경변수들이 생성
- properties 변경시마다 maven build 필요
- Maven 이라는 도구에 종속되는 문제
github.com/sbcoba/spring-camp-2015-sample
sbcoba/spring-camp-2015-sample
실전! 스프링과 함께하는 환경변수 관리 변천사 발표 자료 샘플 . Contribute to sbcoba/spring-camp-2015-sample development by creating an account on GitHub.
github.com
2. 프로파일 기능을 지원하는 스프링 3.1 기능 이용
가. 스프링 3.1 프로파일 기능
- 프레임워크에서 Profile 기능이 추가
Profile에 따른 Bean 정보 제어 ( @Profile("..."), <beans profile="..."> )
- 환경변수 기능이 "Environment" 클래스로 통합관리
- web.xml 또는 애플리케이션 실행시 Profile 파라메터를 넘겨서 선택하는 형태
나. 개선 후 장점
- Maven 종속 부분 제거
but, Properties와 Profile 조합의 단점은 여전히 존재
- 프로퍼티 변경 시 부담감 축소 (No Build!)
- 스프링 Bean 자체도 Profile 별로 구성 가능
github.com/sbcoba/spring-camp-2015-sample/tree/master/spring-camp-env-spring31-sample
sbcoba/spring-camp-2015-sample
실전! 스프링과 함께하는 환경변수 관리 변천사 발표 자료 샘플 . Contribute to sbcoba/spring-camp-2015-sample development by creating an account on GitHub.
github.com
3. Spring Boot의 YAML 설정방법
가. YAML 핵심장점
나. SPRING BOOT와 YAML
다. YAML 적용 후 장점
- 파일 기준 Profile 위주의 구성 -> 문서 내용 위주로 변경
- 환경변수의 구조화
- 중복된 데이터 축소
github.com/sbcoba/spring-camp-2015-sample/tree/master/spring-camp-env-boot-yaml-sample
sbcoba/spring-camp-2015-sample
실전! 스프링과 함께하는 환경변수 관리 변천사 발표 자료 샘플 . Contribute to sbcoba/spring-camp-2015-sample development by creating an account on GitHub.
github.com
728x90반응형'spring' 카테고리의 다른 글
spring-batch-in-action (0) 2021.04.05 오픈소스를 활용한 배치 처리 플랫폼 (0) 2021.04.05 [PMJ] Spring Batch에 대한 생각 (2) (0) 2021.03.26 [PMJ] Spring Batch에 대한 생각 (1) (0) 2021.03.26 Spring Data mongoDB(1.0.0 RC1 이상) 에서 collection에 index 추가 하기 (0) 2021.03.24