DI주입1 12. Dependency Injection 방법 0. 개요 - 이전 포스팅에서 의존성 자동 주입 방법과 그 원리에 대해서 배웠다. - 이번 포스팅에서는 Spring에서 제공하는 다양한 DI 자동 주입 방법에 대해서 알아보자. 1. Constructor(생성자) Injection - Spring은 생성자 주입 방식의 사용을 권장한다. a) 구현 방법 - @Component가 붙은 클래스 내부에 생성자를 만든다. - 생성자에 @Autowired를 부착한다. @Component public class TestServiceImpl implements TestService { private final TestRepository testRepository; @Autowired public TestServiceImpl(TestRepository testReposi.. 2022. 2. 11. 이전 1 다음