• JavaEE笔记(九)


    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>

    我不作恶

    但有权拒绝为善

    我不赞同

    但是我捍卫你不为善的权力

  • 相关阅读:
    iOS设计模式之观察者模式
    iOS设计模式之装饰者模式
    【Dart学习】--之Iterable相关方法总结
    【Dart学习】--之Duration相关方法总结
    【Flutter学习】基本组件之弹窗和提示(SnackBar、BottomSheet、Dialog)
    【Dart学习】--Dart之超级父类之Object
    从零开始实现ASP.NET Core MVC的插件式开发(五)
    从零开始实现ASP.NET Core MVC的插件式开发(四)
    从零开始实现ASP.NET Core MVC的插件式开发(三)
    从零开始实现ASP.NET Core MVC的插件式开发(二)
  • 原文地址:https://www.cnblogs.com/HackerBlog/p/6139643.html
Copyright © 2020-2023  润新知