I am loading property attributes from a .properties file using Spring as follows:
file: elements.properties base.module.elementToSearch=1 base.module.elementToSearch=2 base.module.elementToSearch=3 base.module.elementToSearch=4 base.module.elementToSearch=5 base.module.elementToSearch=6
Spring xml file
file: myapplication.xml <bean id="some" class="com.some.Class"> <property name="property" value="#{base.module.elementToSearch}" /> </bean>
And my .java class
file: Class.java public void setProperty(final List<Integer> elements){ this.elements = elements; }
But when debugging, the parameter elements receive only the last element in the list, therefore there is a list of one element with a value of "6", and not a list of 6 elements.
I tried other approaches, such as adding only the value #{base.module} , but then it did not find any parameter in the properties file.
The workaround is to have a comma separated list in element.properties file, for example:
base.module.elementToSearch=1,2,3,4,5,6
and use it as a String and parse it, but is there a better solution?
java spring placeholder properties-file
RamonBoza Jun 02 '11 at 9:50 a.m. 2011-06-02 09:50
source share