강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

오개발님의 프로필 이미지
오개발

작성한 질문수

스프링 핵심 원리 - 기본편

프로토타입 스코프 - 싱글톤 빈과 함께 사용시 Provider로 문제 해결

빈 등록과 new 차이

작성

·

126

0

삭제된 글입니다

답변 1

0

안녕하세요.ohjinseok님, 공식 서포터즈 OMG입니다.

AnnotationConfigApplicationContext ac new AnnotationConfigApplicationContext(TestBean.classClientBean.classPrototypeBean.class);

TestBean tes ac.getBean(TestBean.class);

tes.addCount(); // 호출1
System.out.println(tes.getCount());

TestBean testBean new TestBean();
tes.addCount();// 호출2
System.out.println(testBean.getCount());

생각 하신 시나리오에서

tes.addCount();를 두번 호출 하는게 맞나요?

감사합니다.

오개발님의 프로필 이미지
오개발

작성한 질문수

질문하기