Announcement Announcement Module
Collapse
No announcement yet.
Loading a property file into a bean property Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loading a property file into a bean property

    I cannot seem to find out how to do this anywhere. I basically have a bean with a java.util.Properties property and I want to load a properties file into it. Like so

    Code:
    <bean id="someBean" class="someClass">
      <property name="configuration">
        <bean class="some.spring.class.propertyloader">
          <property name='file' value='config.properties' />
        </bean>
      </property>
    </bean>

  • #2
    Take a look at PropertiesFactoryBean.

    Comment


    • #3
      thanks a lot! I was confused b/c of the factory bean implementation ( setting properties property to an object of type PropertiesFactoryBean seems strange if you do not realize what is going on ).

      here is what I have and seems to work, is this the recommended way?

      Code:
      <property name="queries">
        <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
          <property name="location" value="classpath:com/domain/model/service/jdbc/sql-queries.properties" />
        </bean>
      </property>

      Comment


      • #4
        If you are using Spring 2 you can make this a little easier.
        http://www.springframework.org/docs/...til-properties

        Comment

        Working...
        X