PropertyPlaceholderConfigurer only works with ApplicationContext

Jul 4, 2010   #java  #spring 

In a Spring application, you can use the PropertyPlaceholderConfigurer to use properties in your Spring configuration.

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location">
        <value>common.properties</value>
    </property>
</bean>
      
<bean id="clientProxyFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
    <property name="serviceClass" value="com.sample.Service"/>
    <property name="address" value="${address}"/>
</bean>

But beware: Replacing the properties with the values from the property file only works if you use an ApplicationContext for retrieving your beans. It will not work when using a BeanFactory.