Autowired

· Spring
Spring 프레임워크에서 @Autowired 어노테이션은 자동 의존성 주입을 강력한 도구로 사용됩니다. @Autowired을 통해 Spring은 Application Context에서 필요한 Bean을 찾아서 해당 필드에 주입합니다. 이를 통해 코드의 가독성과 유지보수성을 높이고, 의존성 주입에 대한 번거로움을 줄일 수 있습니다. @AutoWired 개념 생성자, 필드, 메서드 등의 위치에 사용됩니다. 주로 의존성을 주입받아야 할 대상에 어노테이션을 적용하며 Spring에 해당 객체를 주입하도록 지시합니다. 1. 생성자 주입 @Service public class MyService { private final MyRepository myRepository; @Autowired public MyServi..
· Spring
본 포스팅은 학습용으로, 김영한 님의 강의를 바탕으로 복습용도로 작성되었습니다. 컴포넌트 스캔 과 의존관계 자동 주입 컴포넌트 스캔 컴포넌트 스캔은 스프링이 설정 정보 없이, 자동으로 스프링 빈을 등록하는 것을 말한다. 의존관계도 자동을 주입하는 @Autowired라는 기능도 제공한다. 컴포넌트 스캔을 사용하는 예) AutoAppConfig.java package hello.core; import hello.core.member.MemberRepository; import hello.core.member.MemoryMemberRepository; import org.springframework.context.annotation.Bean; import org.springframework.context.an..
runnnerDevHong
'Autowired' 태그의 글 목록