@Bean public static PropertyPlaceholderConfigurer propertyConfigurer() throws IOException { PropertyPlaceholderConfigurer props = new PropertyPlaceholderConfigurer(); props.setLocations(new Resource[] {new ClassPathResource("environment.properties")}); props.setSearchSystemEnvironment(true); props.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE); return props; }
@Bean PropertyPlaceholderConfigurer configurer() { PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); configurer.setFileEncoding("utf-8"); configurer.setSystemPropertiesMode( PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE); configurer.setLocations( new org.springframework.core.io.Resource[] { new ClassPathResource("config_test.properties", SpringFeatureTest.class), new ClassPathResource("config.properties") }); return configurer; }
/** * 프로퍼티 홀더는 다른 빈들이 사용하는 프로퍼티들을 로딩하기 때문에, static 메소드로 실행된다. 다른 일반 빈들이 만들어지기전에 먼저 만들어져야 한다. * * @return */ @Bean public /* static 메소드에요! */ static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); ppc.setLocations(new Resource[] {new ClassPathResource(APP_CONFIG_FILE_PATH)}); return ppc; }