ITWeb/개발일반

[Spring] Intellij Community + Springboot Profile 활용

jjeong 2021. 10. 20. 16:43

Intellij Community + Spring Boot Framework Profiles

intellij 에서 바로 springboot application 을 실행 시킬 때 환경 설정 파일을 분리해서 사용하기 위한 내용입니다.
Intellij Community 같은 경우 Ultimate 이랑 다르기 때문에 아래와 같은 방법으로 사용 하시면 됩니다.

application.yml 내 "---" 을 이용한 방식은 검색 해 보시면 많이 나와 있으니 넘어 가겠습니다.
아래 방식이 제가 하고 싶은 방법이라서 기술 합니다.

resources/
  + application.yml
  + application-local.yml

Edit Configuration -> Build and run 에서 Modify options 를 선택해서 add VM options 선택 -> -Dspring.profiles.active=local 입력
또는
Environment variables 에서 아래 key=value 입력 합니다.
spring.profiles.active=local

이와 같이 설정 하고 Application 을 실행 시켜 보시면 동작하는 걸 확인해 볼 수 있습니다.