'profile'에 해당되는 글 2건

  1. 2021.10.20 [Spring] Intellij Community + Springboot Profile 활용
  2. 2016.03.09 [Maven] 간단 Profile을 이용한 서비스 환경 구성

[Spring] Intellij Community + Springboot Profile 활용

ITWeb/개발일반 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 을 실행 시켜 보시면 동작하는 걸 확인해 볼 수 있습니다.

 

:

[Maven] 간단 Profile을 이용한 서비스 환경 구성

ITWeb/개발일반 2016. 3. 9. 10:32

개발과 운영 또는 test, qa, stage 등 다양한 개발 및 서비스 환경이 있을 수 있습니다.

그렇다 보니 RDBMS를 사용하는 경우 연결 정보를 다르게 가져가야 하는데요.

이럴경우 maven profile 기능을 이용해서 구성이 가능 합니다.

기억력에 의존할 나이가 넘었으므로 기록해 보겠습니다.

(구글링 해보시면 자세하게 정리된 문서 많이 나와 있습니다.)


참고문서)

http://maven.apache.org/guides/introduction/introduction-to-profiles.html


저는 간단하게 development 환경과 production 환경 두 가지만 설정 하도록 하겠습니다.


pom.xml 설정)

<profiles>
<profile>
<id>development</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<env>development</env>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<env>production</env>
</properties>
</profile>
</profiles>

<build>
<resources>
<resource>
<directory>src/main/resources/${env}</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources/${env}</directory>
</testResource>
</testResources>
</build>


빌드 옵션)

$ mvn clean package -P development


디렉토리 구성)

src/main/resources/development

src/main/resources/production


※ src/test 는 여기에 구성하지 않았습니다. ^^;


: