Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

프로그래밍 끄적끄적

[SpringBoot] 컴포넌트 스캔 필터링 본문

백엔드/스프링

[SpringBoot] 컴포넌트 스캔 필터링

soeunkk 2021. 9. 3. 15:09

🌳 Filter 종류

    ▪ includeFilters: 조건을 만족하는 클래스만 스캔한다.

    ▪ excludeFilters: 조건을 만족하는 클래스는 제외하고 스캔한다.

 

- 예문

1
2
3
4
@ComponentScan(
    includeFilters = @ComponentScan.Filter(type= FilterType.ANNOTATION, classes=MyIncludeComponent.class),
    excludeFilters = @ComponentScan.Filter(type=FilterType.ANNOTATION, classes=MyExcludeComponent.class)
)
cs

 

🌳 FilterType 옵션

    ▪ ANNOTATION: 디폴트값이며, 어노테이션을 인식해서 동작한다.

    ▪ ASSIGNABLE_TYPE: 지정한 타입과 자식 타입을 인식해서 동작한다.

    ▪ ASPECTJ: AspectJ 패턴을 이용하여 필터링한다.

    ▪ REGEX: 정규 표현식을 이용하여 필터링한다.

    ▪ CUSTOM: TypeFilter라는 인터페이스를 구현해서 처리한다.

 

'백엔드 > 스프링' 카테고리의 다른 글

[SpringBoot] 자동주입(@Autowired)  (0) 2021.09.07
[SpringBoot] 의존관계 주입  (0) 2021.09.07
[SpringBoot] 컴포넌트 스캔과 자동 주입  (0) 2021.09.03
[SpringBoot] 싱글톤  (0) 2021.09.01
[SpringBoot] BeanDefinition  (0) 2021.09.01
Comments