摘要: 1、默认情况下,在Bean容器被实例化的时候,bean对象将被创建:public class PersonServiceImpl implements PersonIService { public PersonServiceImpl(){ System.out.println("初始化!!!")... 阅读全文
posted @ 2015-11-06 16:25 Bodi 阅读(223) 评论(0) 推荐(0) 编辑
摘要: Singleton作用域(默认) 当一个bean的作用域为singleton,那么Spring Ioc容器中只会存在一个共享的bean实例,并且所有对bean的请求,只要id与该bean定义相匹配,则只会返回bean的同一实例。也就是说,当把一个bean定义设置为singleton作用域时,S... 阅读全文
posted @ 2015-11-06 14:32 Bodi 阅读(429) 评论(0) 推荐(0) 编辑
摘要: 1、使用类构造器进行实例化测试代码:@Test public void test() { ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml"); PersonIService personIService=... 阅读全文
posted @ 2015-11-06 11:32 Bodi 阅读(236) 评论(0) 推荐(0) 编辑