스프링으로 만든 애플리케이션은 일반적으로 환경 격리를 위해 프로파일을 구분한 프로퍼티 파일을 사용함.
이 프로퍼티 파일을 적용하는 방법은 보통 다음과같다.
Dspring.profiles.active=xxx 가 추가되어 JVM에게 전달됨. 즉 2번과 같음.Dspring…이나 -spring… 등으로 프로파일 옵션을 전달한다. 이 값은 JVM에게 전달된다.P 옵션을 사용한다. → 여기가 조금 혼동할만한 여지가 있다.
코드 설정의 예시
<profiles>
<profile>
<id>prod</id>
<properties>
<spring.profiles.active>prod</spring.profiles.active>
</properties>
</profile>
</profiles>
이렇게 pom.xml에 설정한다면, -P 옵션으로 전달된 값이 스프링의 프로파일 선택 옵션과도 이어지게 된다.
스프링 부트는 많은걸 해준다.