0

I've a properties file like this :

firstproperty=1,2,3,4
secondproperty=47,998,120
thirdproperty=54

My properties file is well defined in my Spring configuration as property for my PropertyPlaceHolderConfigurer bean.

I want to load values in a

HashMap<String, ArrayList<String>> 

like this :

<util:map id="properties" map-class="java.util.HashMap">
    <entry key="first" value="${firstproperty}" />
    <entry key="second" value="${secondproperty}" />
    <entry key="three" value="${thirdproperty}" />
</util:map>

The problem is that for each entry, multiple values separated by commas count as one value. I tried to configure value-type of my util-map to an ArrayList but it was unsuccessful. Any idea ?

P.S : I use Spring 3.2.

  • You can visit this link:http://stackoverflow.com/questions/12576156/reading-a-list-from-properties-file-and-load-with-spring-annotation-value Hope it's helpful. – freeman Dec 02 '13 at 10:34
  • @Freeman thank you, actually I had read it and I was not totally satisfied, cause I need to manage my beans injections into Spring configuration file and not in Java code. – user2107034 Dec 02 '13 at 11:02

1 Answers1

1

I searched Spring EL in config file, maybe this is what you want:

<bean id="taxCalculator" class="org.spring.samples.TaxCalculator">
<property name="defaultLocale" value="#{ systemProperties['user.region'] }.split(',')"/>

<!-- other properties -->

I am not sure about the location of split method, you can try yourself to find the correct way. For more details, please refer:http://docs.spring.io/spring/docs/3.0.x/reference/expressions.html

freeman
  • 399
  • 1
  • 3
  • 11