Tags

,

links:
http://www.baeldung.com/2012/02/06/properties-with-spring
http://blog.springsource.org/2011/02/15/spring-3-1-m1-unified-property-management/
http://www.javaworld.com/community/node/8309

@PropertySource
– since 3.1 using property source to inject properties files
– used in @Configuration classes
– from javadoc: in order to resolve ${…} placeholders in definitions or @Value annotations using properties from a PropertySource, one must register a PropertySourcesPlaceholderConfigurer.
Must be explicitly registered using a static @Bean method when using @Configuration classes.
– Pre-3.1, defining a XML element automatically registers a new PropertyPlaceholderConfigurer bean in the Spring Context. Also true for 3.1+, for backwards compatibility purposes, the XSD schemas are not updated to the 3.1 versions.
– For 3.1+, instead of PropertyPlaceholderConfigurer, the new introduced PropertySourcesPlaceholderConfigurer is used when exists.

– PropertyPlaceholderConfigurer is a common example of BFPP bean factory post proc, substitute ${variables} in bean defs from properties.

Advertisements