Injecting .properties file in Spring

August 8th, 2007 | Categories: Default | Tags:

A few days back I came across a piece of code from Spring here it is :


<bean
id=”propertyConfigurer” class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>
    <property name=”locations”>
      <list>       
        <value>classpath:file.properties</value>
        <value>classpath:validation.properties</value>
      </list>
    </property>
</bean>

Now, what this enables us to do is to inject the values from property file in to Spring Beans, neat isn’t it ?

<bean id=”fileProcessor” class=”a.b.c.d.SomeImpl”>
<
property name=”srcFileName” value=”${file.srcFileName}”/>
</bean>

No comments yet.
TOP