1. 程式人生 > >Spring原始碼解析(二)——元件註冊2

Spring原始碼解析(二)——元件註冊2

 

 

import com.ken.service.BookService;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;

@Configuration
@ComponentScan(
		value = "com.ken",
		includeFilters = {
				@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class}),
				@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {BookService.class})
		},
		useDefaultFilters = false)
public class MainConfig {
}

 

自定義FilterType指定過濾規則

 

https://blog.csdn.net/qq_34823865/article/details/79996936