Search code examples
javaspringspring-ioc

Write a spring bean with a constructor that contains a list of values from property file


Could you help me what the proper way of writing spring bean with parameter of list values which I get from .properties file.

  <bean id="property" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="classpath:dateFormat.properties" />
</bean>

<bean id="directoryMarshallerFolder1" class="threadService.DirectoryMarshalerFolder1">

    <constructor-arg>
        <list>
            ...
            <value = "${folder1.path}"/> ?????
            <value = "${folder2.path}"/> 
            ...
        </list>
    </constructor-arg>

</bean>

Solution

  • I've already found the result.

     <constructor-arg> <list> <value>${folder1.path}</value> <value>${folder2.path}</value> </list> </constructor-arg>