자라선

12. Profile 본문

Develop/Spring Boot

12. Profile

자라선 2020. 7. 27. 16:17

@Profile

Spring Boot 는 선택하는 profile에 따라 달리 실행할 수 있다.

 

application.properties

spring.profiles.active=mysql

OR

java -jar <project>.jar --spring.profiles.active=oracle


application.properties 추가 및 활성화

다른 properties 파일의 내용을 추가 할 수도 있다.

이때 추가하는 properties의 네이밍 룰이 있으며 아래와 같이 작성

application-<이름>.properties

 

추가inlcude 를 사용하며 추가하는 명은 <이름> 으로 추가

application.properties

spring.profiles.include=db

 

활성화 @Profile 어노테이션과 동일

application.properties

spring.profiles.active=db

OR

java -jar <project>.jar --spring.profiles.active=db

 

 

'Develop > Spring Boot' 카테고리의 다른 글

14. Test  (0) 2020.07.27
13. Logging  (0) 2020.07.27
11. 외부설정  (0) 2020.07.27
10. SpringApplication 기본  (0) 2020.07.27
9. JAR 실행 및 패키징 원리  (0) 2020.07.27
Comments