컴포넌트 스캔 : 스프링이 제공하는 기능으로, 설정 정보가 없어도 자동으로 스프링 빈을 등록
→ @Component
의존관계 자동 주입 → @Autowired
AutoAppConfig.java
package hello.core;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import static org.springframework.context.annotation.ComponentScan.*;
@Configuration
@ComponentScan(
excludeFilters = @Filter(type = FilterType.ANNOTATION, classes =
Configuration.class))
public class AutoAppConfig {
}
@ComponentScan 을 붙여서 사용
기존 AppConfig와 달리 @Bean 으로 등록한 클래스가 하나도 없다
기존에 @Configuration 붙여서 만든 설정 정보도 자동으로 등록되므로 제외시켜야 함
이름 그대로 @Component 애노테이션이 붙은 클래스를 스캔해 스프링 빈으로 등록