Results 1 to 4 of 4

Thread: Loading a property file into a bean property

  1. #1
    Join Date
    Aug 2007
    Location
    Chattanooga, TN
    Posts
    4

    Default 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. #2
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    Take a look at PropertiesFactoryBean.

  3. #3
    Join Date
    Aug 2007
    Location
    Chattanooga, TN
    Posts
    4

    Default

    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>

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •