@Component가 Spring Boot에 등록되는 과정
·
Spring
@Component는 어떻게 Spring Bean으로 등록될까@Component(혹은 @Service, @Repository 등)를 붙이면 Spring이 알아서 객체를 만들어 관리해 준다. 이 "알아서"의 내부 과정을 SpringApplication.run()부터 싱글톤 캐시에 올라가기까지 단계별로 따라가 본다.본격적으로 들어가기 전에 Bean이 무엇인지부터 짚고 시작하자.1. Bean이란?Spring에서는 객체를 직접 new 해서 쓰지 않는다. MemberService memberService = new MemberService();이런 코드를 개발자 대신 Spring이 수행하고, 생명주기까지 관리한다. 이렇게 Spring 컨테이너가 생성·관리하는 객체를 Bean이라고 부른다. 2. 등록 과정의 시..