Dependency Injection
예제로 배우는 스프링 프레임워크 입문 - 의존성 주입 (Dependency Injection)
의존성 주입 (Dependency Injection) 필요한 의존성을 어떻게 받아올 것인가.. @Autowired / @Inject를 어디에 붙일까? 생성자 필드 Setter 1. Constructor public OwnerController(OwnerRepository clinicService, /*VisitRepository visits*/) { this.owners = clinicService; //this.visits = visits; } @AutoWired -> 4.3부터 어떠한 클래스에 생성자가 하나뿐이고 생성자로 주입받는 Reference 변수들이 Bean으로 등록되어 있다면 그 Bean을 자동으로 주입해주도록 추가 되었음 즉 4.3이상부터 Autowired 생략 가능 2. field pri..