개발
환경 설정 값에 따라 기능 실행하기
escser
2020. 6. 10. 17:23
active 값과는 별도로 properties안의 설정값에 따라 기능을 분리하겠다.
@ConditionalOnProperty
@Bean
@ConditionalOnProperty(name="type", havingValue="B")
public void test() {
System.out.println("amazing");
}
properties에 정의된 key값이 type인 value가 B일 경우에만 test()를 실행시킨다.
이 외에도 다양한 @Conditional 종류가 있다.