목록@Profile (1)
컴공생의 다이어리
[스프링 부트, Spring Boot] @Profile, @ActiveProfiles
@Profile 빈이나 컴포넌트에 프로필을 구분하여 빈을 로드하고 싶은 경우 @Profile을 활용하면 된다. 아래와 같이 @Profile을 통해 프로필(profile)이 active될 때 어떤 빈 혹은 컴포넌트를 등록할지 결정할 수 있다. @Configuration @Profile("prod") public class ProdConfig{ @Bean public DataSource dataSource(){ // ... 생략 } } @Configuration @Profile("dev") public class DevConfig{ @Bean public DataSource dataSource(){ // ... 생략 } } 프로필 이름 앞에 NOT 연산자인 !를 접두사로 붙여 프로필에서 제외시킬 수 있다. ..
Development/Spring & SpringBoot
2024. 1. 15. 23:00