1.@CompentScan与@CompentScans
@CompentScan
为扫描包注解,只能作用于类上,一个类上可以有多个@CompentScan注解。
等价于 <context:component-scan base-package="com.java" ></context:component-scan>
使用了@ComponentScan注解后,指定包下的@Controller,@Service,@Repository,@Compent才会生效。
@component注解属性说明:
//excludeFilters = Filter[] :指定扫描的时候按照什么规则排除那些组件
//includeFilters = Filter[] :指定扫描的时候只需要包含哪些组件
//FilterType.ANNOTATION:按照注解
//FilterType.ASSIGNABLE_TYPE:按照给定的类型;
//FilterType.ASPECTJ:使用ASPECTJ表达式
//FilterType.REGEX:使用正则指定
//FilterType.CUSTOM:使用自定义规则
特别注意:过滤器必须实现TypeFilter接口,同时要使过滤器生效,必须将useDefaultFilters设置为false,该属性默认为true。