Collections can be used in spring by the following way
<bean id="helloWorldService2"
class="com.searchendeca.application.HelloWorld2">
<property name="personMap">
<map>
<entry key="name" value="Syed Ghouse Habib" />
<entry key="age" value="27" />
</map>
</property>
<property name="nameList">
<list>
<value>Syed</value>
<value>Ghouse</value>
</list>
</property>
<property name="nameSet">
<set>
<value>Syed</value>
<value>Ghouse</value>
<value>Syed</value>
<value>Ghouse</value>
</set>
</property>
</bean>
package com.searchendeca.application;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class HelloWorld2{
private List<String> nameList= new ArrayList<>();
public List<String> getNameList() {
return nameList;
}
public void setNameList(List<String> nameList) {
this.nameList = nameList;
}
private Map<String,String> personMap= new HashMap<>();
public Map<String, String> getPersonMap() {
return personMap;
}
public void setPersonMap(Map<String, String> personMap) {
this.personMap = personMap;
}
private Set<String> nameSet= new HashSet<>();
public Set<String> getNameSet() {
return nameSet;
}
public void setNameSet(Set<String> nameSet) {
this.nameSet = nameSet;
}
}
No comments:
Write comments