博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring学习笔记二-collection
阅读量:7009 次
发布时间:2019-06-28

本文共 3223 字,大约阅读时间需要 10 分钟。

  hot3.png

package collection;import nocollection.Car;import java.util.List;//Personpublic class Person {    String name;    int age;    List
 cars;    public Person() {    }    public Person(String name, int age, List
 cars) {        this.name = name;        this.age = age;        this.cars = cars;    }    public List
 getCars() {        return cars;    }    public void setCars(List
 cars) {        this.cars = cars;    }    public String getName() {        return name;    }    public int getAge() {        return age;    }    public void setName(String name) {        this.name = name;    }    public void setAge(int age) {        this.age = age;    }    @Override    public String toString() {        return "Person{" +                "name='" + name + '\'' +                ", age=" + age +                ", cars=" + cars +                '}';    }}
package collection;import java.util.Properties;//Datasourcepublic class DataSource {    private Properties properties;    DataSource() {    }    public DataSource(Properties properties) {        this.properties = properties;    }    public Properties getProperties() {        return properties;    }    public void setProperties(Properties properties) {        this.properties = properties;    }    @Override    public String toString() {        return "DataSource{" +                "properties=" + properties +                '}';    }}

 package collection;import nocollection.Car;import java.util.List;import java.util.Map;public class PersonMap {    String name;    int age;    Map
 cars;    public PersonMap() {    }    public PersonMap(String name, int age, Map
 cars) {        this.name = name;        this.age = age;        this.cars = cars;    }    public Map
 getCars() {        return cars;    }    public void setCars(Map
 cars) {        this.cars = cars;    }    public String getName() {        return name;    }    public int getAge() {        return age;    }    public void setName(String name) {        this.name = name;    }    public void setAge(int age) {        this.age = age;    }    @Override    public String toString() {        return "PersonMap{" +                "name='" + name + '\'' +                ", age=" + age +                ", cars=" + cars +                '}';    }}
package collection;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;public class Main {    public static void main(String[] args) {        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");        Person person4= (Person) ctx.getBean("person4");        System.out.println(person4);        PersonMap persona = (PersonMap) ctx.getBean("persona");        System.out.println(persona);        DataSource ds = (DataSource)ctx.getBean("datasource");        System.out.println(ds);        Person person5 = (Person) ctx.getBean("person5");        System.out.println(person5);        Person person6 = (Person) ctx.getBean("person6");        System.out.println(person6);    }}

转载于:https://my.oschina.net/jimyao/blog/631565

你可能感兴趣的文章
Docker架构、镜像和容器
查看>>
LNMP架构搭建(脚本)
查看>>
作为一名Java程序员的必修课+java_框架面试题(含答案)
查看>>
图片文字转word文档文字的方法
查看>>
idea在线生成注册码地址2018已经验证可用
查看>>
AJPFX关于StringBuffer,StringBuilder类总结(二)
查看>>
keepalived+lvs实现lvs的高可用
查看>>
linux下压缩与解压缩以及打包命令详解
查看>>
深入浅出JDBC(二) - Dbutils
查看>>
elasticsearch5.0 环境搭建
查看>>
redis pipe管道
查看>>
git:rejected because the tip of your current branch is behind
查看>>
我的友情链接
查看>>
基层公务员自述:每天擦桌子证明自己还活着(全文)
查看>>
电话营销六种经典开场白
查看>>
wxPython图像相关处理
查看>>
jdbc链接oracle数据库
查看>>
重新配置Synology磁盘模式到RAID5
查看>>
ORA-00845: MEMORY_TARGET not supported on this system
查看>>
完美解决failed to open stream: HTTP request failed!(file_get_contents引起的)
查看>>