Thanks for the quick responses!
To test this out, I've created a small class that has a String array and a List of Strings. I'm using the same property to set the values for both. I'm not even using a properties file, just setting it in the "properties" map of the PropertyPlaceholderConfigurer (same outcome if I do use a properties file though). As you can see from the output below, the String array is populated correctly while the String List contains one entry which is the comma delimited list.
By the way, I'm using Spring 2.0.1
Here's the configuration xml:
Code:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties">
<map>
<entry key="strings" value="abc,def,ghi"/>
</map>
</property>
</bean>
<bean id="test" class="com.pics.ATest" init-method="init">
<property name="stringArray">
<value>${strings}</value>
</property>
<property name="stringList">
<value>${strings}</value>
</property>
</bean>
And the class:
Code:
public class ATest {
private String[] stringArray;
private List<String> stringList;
public void init() {
System.out.println("stringArray values: ");
for (String str : stringArray) {
System.out.println(" " + str);
}
System.out.println("stringList values: ");
for (String str : stringList) {
System.out.println(" " + str);
}
}
public void setStringArray(String[] stringArray) {
this.stringArray = stringArray;
}
public void setStringList(List<String> stringList) {
this.stringList = stringList;
}
public static void main(String[] args) {
ConfigurableApplicationContext context = new FileSystemXmlApplicationContext("classpath:application-context.xml");
ATest test = (ATest)context.getBean("test");
}
}
And the output:
Code:
stringArray values:
abc
def
ghi
stringList values:
abc,def,ghi