propertiesfactorybean vs propertyplaceholderconfigurer spring?

java, spring

Solution

`PropertiesFactoryBean` is a `FactoryBean` implementation which reads a properties file and exposes that as an `Properties` object in the applicationcontext.

`PropertyPlaceHolderConfigurer` is a `BeanFactoryPostProcessor` implementation that reads a property file and uses that property file to replace placeholder variables (${somename}) with actual values. The read properties aren't available as a `Properties` object.

Problem

spring has two ways to load property files using either propertiesfactorybean or propertyplaceholderconfigurer. Could u please explain the difference between them and when to use what? Thanks!

Original source