본문 바로가기

Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Total
Today
Yesterday
관리 메뉴

7-3 본문

집에서 공부

7-3

잠이올때마다 2019. 3. 6. 23:13

스프링 빈은 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를 사용하면 같다는 결과가 나온다~ 

'집에서 공부' 카테고리의 다른 글

8-2  (0) 2019.03.07
8-1  (0) 2019.03.06
7-1 7-2  (0) 2019.03.06
6-2  (0) 2019.03.06
6 DI설정  (0) 2019.03.06
Comments