Class PlaceholderConfigurerSupport

  • All Implemented Interfaces:
    Aware, BeanFactoryAware, BeanNameAware, BeanFactoryPostProcessor, Ordered, PriorityOrdered
    Direct Known Subclasses:
    PropertyPlaceholderConfigurer, PropertySourcesPlaceholderConfigurer

    public abstract class PlaceholderConfigurerSupport
    extends PropertyResourceConfigurer
    implements BeanNameAware, BeanFactoryAware
    Abstract base class for property resource configurers that resolve placeholders in bean definition property values. Implementations pull values from a properties file or other property source into bean definitions.

    The default placeholder syntax follows the Ant / Log4J / JSP EL style:

    ${...}
    Example XML bean definition:
     <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"/>
       <property name="driverClassName" value="${driver}"/>
       <property name="url" value="jdbc:${dbname}"/>
     </bean>
     
    Example properties file:
    driver=com.mysql.jdbc.Driver
     dbname=mysql:mydb
    Annotated bean definitions may take advantage of property replacement using the @Value annotation:
    @Value("${person.age}")
    Implementations check simple property values, lists, maps, props, and bean names in bean references. Furthermore, placeholder values can also cross-reference other placeholders, like:
    rootPath=myrootdir
     subPath=${rootPath}/subdir
    In contrast to PropertyOverrideConfigurer, subclasses of this type allow filling in of explicit placeholders in bean definitions.

    If a configurer cannot resolve a placeholder, a BeanDefinitionStoreException will be thrown. If you want to check against multiple properties files, specify multiple resources via the locations property. You can also define multiple configurers, each with its own placeholder syntax. Use ignoreUnresolvablePlaceholders to intentionally suppress throwing an exception if a placeholder cannot be resolved.

    Default property values can be defined globally for each configurer instance via the properties property, or on a property-by-property basis using the default value separator which is ":" by default and customizable via setValueSeparator(String).

    Example XML property with default value:

       
     
    Since:
    3.1
    Author:
    Chris Beams, Juergen Hoeller
    See Also:
    PropertyPlaceholderConfigurer, PropertySourcesPlaceholderConfigurer