<context:property-placeholder ... />
is the XML equivalent to the PropertyPlaceholderConfigurer
https://dzone.com/articles/spring-core-diving-into-the-propertyplaceholdercon
@Configuration public class AppConfig { @Bean public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new
PropertySourcesPlaceholderConfigurer();
propertySourcesPlaceholderConfigurer.setLocations(new
ClassPathResource("application-db.properties")); //propertySourcesPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true); //propertySourcesPlaceholderConfigurer.setIgnoreResourceNotFound(true); return propertySourcesPlaceholderConfigurer; } }
--------------------------------------------
@Configuration @PropertySource("/foo/bar/services.properties") public class ServiceConfiguration { @Autowired Environment environment; @Bean public javax.sql.DataSource dataSource( ){ String user = this.environment.getProperty("ds.user"); ... } }
No comments:
Post a Comment