@Configuration 설정파일 아무데서나, 없으면 아무 클래스나 만들어 @Configuration설정
@Configuration
public class WebConfig {
//===[ Profile Setting ]======================
// @Configuration 아래 profile
@Profile("prod")
@Bean(name="emConfig")
public EmConfig getProd() {
return new EmConfig(true);
}
}
편의를 위해 static 프라퍼티를 설정한다.
메소드로 읽어들일 경우에는 사용하는 쪽에서 @Autowired 또는 @Injection 으로 사용
아래와 같이 설정하면 아무데서나 EmConfig.isProduction 으로 참조해 사용한다.
public class EmConfig {
public static boolean isProduction = false;
public EmConfig(boolean isProd) {
EmConfig.isProduction = isProd;
}
}