Hi,
I want initialize a property of the type List or Map but from an external *.properties file. is this possible?
Hi,
I want initialize a property of the type List or Map but from an external *.properties file. is this possible?
Doing a Map is easy because a Properties object implements Map. You can convert a file to a Properties object using PropertiesFactoryBeanOriginally Posted by masrawi
For list you would have to create a List compatible class that could accept a Map. What would you return as each element of the list? In order to write the custom List class you'd have to figure that out.
Can you expand you explanation for me? I am using a PropertyOverrideConfigurer defined as follows in my web application context:
This works perfectly for overriding simple value properties from the external properties file. What I would like to do is override a Map property:Code:<bean id="overrideConfig" class="org.springframework.beans.factory.config.PropertyOverrideConfigurer"> <property name="location"><value>file:///mydir/myprops.properties</value></property> </bean>
How can I define "myMap" from an external file? Any solution is welcome it doesn't have to use the PropertyOverrideConfigurer.Code:<bean id="myBean" class="mystuff.MyBean"> <property name="myMap"> <map> <entry key="2"><value>two</value></entry> <entry key="3"><value>three</value></entry> </map> </property> </bean>
Thanks.
Code:<bean id="myBean" class="mystuff.MyBean"> <property name="myMap"> <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="location"> <value>file:///mydir/myprops.properties</value> </property> </bean> </property> </bean>