You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
빈 스코프
스프링 빈은 기본적으로 싱글톤 스코프로 생성되어 스프링 컨테이너의 시작과부터 종료까지 유지된다.
스프링이 지원하는 스코프
컴포넌트 스캔 자동 등록
수동 등록
프로토타입 스코프
프로토타입 스코프를 스프링 컨테이너에 조회하면 스프링 컨테이너는 항상 새로운 인스턴스를 생성해서 반환함
싱글톤 빈 요청 (디폴트)
스프링 컨테이너에 같은 요청이 와도 같은 인스턴스의 스프링 빈 반환
프로토타입 빈 요청 1
프로토타입 빈 요청 2
3. 스프링 컨테이너는 생성한 프로토타입 빈을 클라이언트에 반환
4. 이후에 같은 요청이 오면 항상 새로운 프로토타입 빈을 생성해서 반환
⭐ 스프링 컨테이너는 프로토타입 빈을 생성하고, 의존관계 주입, 초기화까지만 처리
스프링 컨테이너는 생성된 프로토타입 빈을 관리하지 않는다. 관리할 책임은 빈을 받은 클라이언트에 있다.
➡️
@PreDestory같은 종료 메서드가 호출되지 않음싱글톤 스코프 빈 조회
프로토타입 스코프 빈 조회
@PreDestroy와 같은 종료 메서드가 전혀 실행되지 않음➡️ 프로토타입 빈에 대한 관리나 종료 메서드에 대한 호출은 클라이언트가 직접 해야함
All reactions