user1914841
user1914841

Reputation: 31

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

Upvotes: 3

Views: 160

Answers (2)

Jigar Joshi
Jigar Joshi

Reputation: 240900

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>

Upvotes: 2

ved
ved

Reputation: 909

You can make different properties in according to region , when server will start all the properties file will load.You can make PropertiesFileReader.java file which will read u'r properties.

Upvotes: 1

Related Questions