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.
Uh oh!
There was an error while loading. Please reload this page.
-
컴포넌트 스캔과 자동 의존관계 설정
참고: helloController는 스프링이 제공하는 컨트롤러여서 스프링 빈으로 자동 등록된다.
@Controller가 있으면 자동 등록됨생성자에
@Autowired가 있으면 스프링이 연관된 객체를 스프링 컨테이너에서 찾아서 넣어준다.스프링 빈을 등록하는 2가지 방법
@Component 어노테이션이 있으면 스프링 빈으로 자동 등록된다.@Controller컨트롤러가 스프링 빈으로 자동 등록된 이유도 컴포넌트 스캔 때문이다.@Component를 포함하는 다음 애노테이션도 스프링 빈으로 자동 등록된다.자바 코드로 직접 스프링 빈 등록하기
3, 생성자 주입 : 생성자를 통해서 주입되는 방법
실무에서는
@Autowired를 통한 DI는 helloController, memberService등과 같이 스프링이 관리하는 객체에서만 동작한다.
Beta Was this translation helpful? Give feedback.
All reactions