Properties object is similar to Map based collection, only difference is keys also strings and values also strings. In case of Map based collection key can be any object and value also can be any object.
To inject Properties into a spring bean following steps are involved: –
Step 1: –Make java.util.Properties type variable as dependency in the spring bean.
Step 2:-To indicate the spring container to create the Properties object make use of tag.
Step 3: –To specify each element of the Properties object make use of tag.
e.g.: –
<bean name=”h” class=”com.nit.spring.HelloBean”>
<property name=”properties”>
<props>
<prop key=”name”> Rama < /prop>
<prop key=”address”> Hyderabad < /prop>
< /props>
< /property>
< /bean>
Note: –value of the key attribute becomes the key of the properties of Properties object. The content of tag become value of the property of Properties object.