7-3 본문
스프링 빈은 scope를 가지고 있다... -> 객체의 범위가 어디까지인가
ex)
AbstractApplicationContext ctx = new GenericXmlApplicationContext("classpath:applicationCTX.xml");
Student student1 = ctx.getBean("student1", Student.class);
System.out.println("이름"+ student1.getName());
System.out.println("나이"+ student1.getAge());
Student student2 = ctx.getBean("student1", Student.class);
student2.setName("김동현");
student2.setAge(20);
여기서 똑같은 빈을 들고 오고 있으며
따라서 if 문을 사용해서 조건문 student1 == student2를 사용하면 같다는 결과가 나온다~
Comments