The following is legal Spring config:
<util:map id="beanMap">
<entry key="key1" value-ref="bean1"/>
<entry key="key2" value-ref="bean2"/>
<entry key="key3" value-ref="bean3"/>
</util:map>
<bean id="usesBeanMap" class="...">
<constructor-arg ref="beanMap" />
</bean>
I would like to externalise this map to a .properties
file (or any other kind of file) for deployment config / environment reasons, for example:
<util:properties id="beanProperties" location="file:/bean-value.properties"/>
<bean id="usesBeanProperties" class="...">
<constructor-arg ref="beanProperties" />
</bean>
This doesn't work out of the box, as a Properties
object is effectively a Map<String, String>
, so this needs to be converted somehow, or use a way to tell Spring, that the values are in fact "value-ref
" bean names.
Is there an easy / recommended way to achieve this?