Spring4.0 构造函数配置bean

来源:互联网 发布:淘宝网首页连衣裙 编辑:程序博客网 时间:2024/06/06 02:47


Spring IOC   下面代码就是Spring的IOC

ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");


Spring的两种getBean()

HelloWorld helloworld = (HelloWorld) ctx.getBean("helloworld");
HelloWorld helloworld1 =  ctx.getBean(helloworld.getClass());

.class方式只允许applicationContext.xml中存在唯一的id

0 0
原创粉丝点击