Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring inject values

I am very new to spring and started using. I have a requirement where i have something like properties like regions..US,UK

Regions
-------
US
UK

And when i read US it shud have values something like

US
----
(KEY)primary----VALUE(primaryValue)
(KEY)secondary----VALUE(secondaryValue)

. . similarly

UK
--
(KEY)primary----VALUE(primaryValue)
(KEY)secondary----VALUE(secondaryValue)

. . and the regions might increase as requirement changes and the key value pairs below it too

Someone hint me so i can proceed Thank you in advance

like image 864
user1914841 Avatar asked Mar 11 '26 18:03

user1914841


1 Answers

You need to create two bean a List and a Map, in other word List<Map> is you need

<bean id="regions" class="java.util.ArrayList">
    <constructor-arg>
        <list>
            <ref bean="usMap" />
            <ref bean="ukMap" />                
        </list>
    </constructor-arg>
</bean>

and

<util:map id="usMap" map-class="java.util.HashMap">
    <entry key="primary" value="someValue"/>
    <entry key="secondary" value="someValue"/>
</util:map>
like image 136
jmj Avatar answered Mar 14 '26 10:03

jmj