AutoAppConfig를 만들어서 스프링 컨테이너에 빈을 등록하기 위해서는 탐색 범위를 지정해주는 @ComponentScan이 필수적
ComponentScan 어노테이션을 @SpringBootApplication도 갖고 있기 때문에 스프링 부트를 쓰면 스프링 빈을 등록할 수 있다고 함
package hello.core;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
@Configuration
//@ComponentScan(
// excludeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Configuration.class)
//)
@SpringBootApplication
public class AutoAppConfig {
}

TestAnnotation을 만들어 테스트 진행
// TestAnnotation 생성
package hello.core.annotation;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import java.lang.annotation.*;
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
@Qualifier("TestAnnotation")
@ComponentScan(
excludeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Configuration.class)
)
public @interface TestAnnotation {
}
package hello.core;
import hello.core.annotation.TestAnnotation;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
//@Configuration
//@ComponentScan(
// excludeFilters = @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Configuration.class)
//)
//@SpringBootApplication
@TestAnnotation
@Configuration
public class AutoAppConfig {
}
결과 (정상 작동)
