package com.lei.study_09_13.config; import org.springframework.core.io.Resource; import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.ClassMetadata; import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.filter.TypeFilter; import java.io.IOException; /** * 自定义装配过滤规则(只能约束ComponentScan注解) * * @author LeiLei * @date 2019/9/13 */ public class MyTypeFilter implements TypeFilter { /** * * @param metadataReader 可获取正在扫描的组件 * @param metadataReaderFactory 可获取扫描到的所有组件(就时ComponentScan注解中的BasePackage) * @return true/false */ public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { //1.获取当前组件上的注解 AnnotationMetadata anno = metadataReader.getAnnotationMetadata();
04、组件注册-自定义TypeFilter指定过滤规则
最新推荐文章于 2024-08-19 14:51:10 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)