List、Map、Set的配置

bean

package com.spring.bean;

import java.util.List;
import java.util.Map;
import java.util.Set; public class People {
private String name; // 姓名
private Set<City> cities; // 去过的城市
private List<Examine> examines; // 考核成绩
private Map<String,Job> jobs;// 工作职位
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<City> getCities() {
return cities;
}
public void setCities(Set<City> cities) {
this.cities = cities;
}
public List<Examine> getExamines() {
return examines;
}
public void setExamines(List<Examine> examines) {
this.examines = examines;
}
public Map<String, Job> getJobs() {
return jobs;
}
public void setJobs(Map<String, Job> jobs) {
this.jobs = jobs;
}
@Override
public String toString() {
return "People [name=" + name + ", cities=" + cities + ", examines="
+ examines + ", jobs=" + jobs + "]";
} }

xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="people" class="com.spring.bean.People">
<property name="name" value="高酋" />
<property name="cities">
<set value-type="com.spring.bean.City">
<ref bean="city_1" />
<ref bean="city_2" />
</set>
</property>
<property name="examines">
<list value-type="com.spring.bean.Examine">
<ref bean="examine_1" />
<ref bean="examine_2" />
<ref bean="examine_3" />
</list>
</property>
<property name="jobs">
<map key-type="java.lang.String" value-type="com.spring.bean.Job">
<entry>
<key>
<value>职位一</value>
</key>
<ref bean="job_1" />
</entry>
<entry>
<key>
<value>职位二</value>
</key>
<ref bean="job_2" />
</entry>
</map>
</property>
</bean>
<!-- city bean -->
<bean id="city_1" class="com.spring.bean.City">
<property name="name" value="四川" />
</bean>
<bean id="city_2" class="com.spring.bean.City">
<property name="name" value="北京" />
</bean>
<!-- examine bean -->
<bean id="examine_1" class="com.spring.bean.Examine">
<property name="score" value="79" />
</bean>
<bean id="examine_2" class="com.spring.bean.Examine">
<property name="score" value="67" />
</bean>
<bean id="examine_3" class="com.spring.bean.Examine">
<property name="score" value="81" />
</bean>
<!-- job bean -->
<bean id="job_1" class="com.spring.bean.Job">
<property name="name" value="厨师" />
</bean>
<bean id="job_2" class="com.spring.bean.Job">
<property name="name" value="维修师" />
</bean>
</beans>

最新文章

  1. ucos实时操作系统学习笔记——操作系统在STM32的移植
  2. css知识点整理
  3. 诺基亚N900使用技巧
  4. Python图表绘制:matplotlib绘图库入门
  5. QT学习之路--创建一个对话框
  6. SpringMVC实现上传和下载
  7. 再不用担心DataRow类型转换和空值了(使用扩展方法解决高频问题)
  8. JSONP(处理跨域问题)
  9. java在线截图---通过指定的URL对网站截图
  10. ios 刷新BUG
  11. selenium通过WebDriverWait实现ajax测试
  12. 目录导航「深入浅出ASP.NET Core系列」
  13. Problem J. Journey with Pigs
  14. Python特点
  15. CPU 架构 —— ARM 架构
  16. ML: 聚类算法-K均值聚类
  17. alpha七天冲刺计划(更新ing)
  18. js中var与let
  19. Emoji表情符号录入MySQL数据库报错的解决方案
  20. [Java]基础.端口

热门文章

  1. 通过office365门户修改邮箱大小限制
  2. EF的连表查询Lambda表达式和linq语句
  3. aws rhel 7 安装GUI ,配置VNC
  4. Mysql 安装服务无法启动解决方案与使用的一般使用指令
  5. Anaconda 安装和使用
  6. Java多线程和并发基础面试总结
  7. Python学习之路 (五)爬虫(四)正则表示式爬去名言网
  8. Java基础加强之集合
  9. virtualbox+vagrant学习-2(command cli)-7-vagrant login命令
  10. 理解JavaScript继承(一)