Saturday, December 01, 2012

Spring: Creating a java.util.Properties Bean

The easiest way to create a java.util.Properties bean in Spring is with a PropertiesFactoryBean as shown in the example below:
<bean id="emailProperties"
      class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  <property name="properties">
    <value>
        smtp.host=mail.host.com
        from=joe.bloggs@domain.com
        to=${mail.recipients}
    </value>
  </property>
</bean>
Spring will parse the key=value pairs and put them into the Properties object.

1 comment:

  1. this is very greatful and informatic helpful Can I quote a post in your blog with the link to you? i want to book mark it. and please visit for my site

    Thanks
    aleix
    Property in Gurgaon, New Residential Property in Gurgaon.

    Thanks & Regards
    nisha
    aleixpetersonnn@gmail.com
    011- 22626320

    ReplyDelete