인기 있는 카테고리

주제별로 모아 봤어요

스프링 어노테이션과 빈(Bean), 그리고 IoC와 DI
·
Java/정리
스프링은 객체를 누가 만들까?스프링 강의나 튜토리얼을 따라 첫 프로젝트를 만들면, @Service를 붙이고 생성자로 Repository를 받는 코드를 그대로 따라 치게 된다. 실행하면 잘 돌아가는데, 그 객체를 new 하는 코드는 프로젝트 어디에도 없다. 돌아가니까 넘어가지만, 누가 이 객체를 만들어 넣어 주는지 설명해 보라고 하면 막히기 쉽다.@Servicepublic class OrderService { private final OrderRepository orderRepository; public OrderService(OrderRepository orderRepository) { this.orderRepository = orderRepository; }}"new Ord..