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.
-
4.스프링 빈과 의존관계
1️⃣컴포넌트 스캔과 자동 의존관계 설정
컴포넌트 스캔으로 자동으로 의존관계 설정하는 방법
@Component: Component 애노테이션이 있으면 스프링 빈으로 자동 등록된다.@Controller: 컨트롤러가 컴포넌트 스캔을 통해서 스프링 빈에 등록 되도록 해준다. → @Cotroller 내부에를 보면 @component가 들어있다.생성자에 @Autowired가 있으면 스프링이 연관된 객체를 스프링 컨테이너에서 찾아서 넣어준다.
이것을 객체 의존관계를 외부에서 넣어주는 것을 DI(Dependency Injection), 의존성 주입이라고 한다.
➡️스프링 빈을 등록하는 2가지 방법
참조 링크 : 싱글톤에대해서
2️⃣자바 코드로 직접
DI 방법은 3가지 있다.
Beta Was this translation helpful? Give feedback.
All reactions