@Autowired의 기본 간단 정리
@Autowired란? 의존성을 주입 할 때 사용하는 어노테이션으로 의존 객체의 타입에 해당하는 bean을 찾아주는 역할을 한다. 사용 가능한 위치 생성자(스프링 4.3부터 생략 가능) Setter 필드 생성자에 @Autowired (스프링 4.3부터 생략가능) @Service public class TestService { TestRepository testRepository; @Autowired public TestService(TestRepository testRepository) { this.testRepository = testRepository; } } public class TestRepository { .... } 위 코드에서 TestRepository의 의존성 주입이 작동할까? 당연히 작..
Back-end/Spring
2022. 8. 4. 22:25