<!-- 自动扫描,base-package 属性指定了需要扫描的类包,类包及其递归子包中所有的类都会被处理-->
<context:component-scan base-package="com.chen">
<!-- 排除模拟实现类
<context:exclude-filter type="regex" expression="com.chen.service.mockimpl.*"/>-->
<!-- 排除真实实现类 -->
<context:exclude-filter type="regex" expression="com.chen.service.impl.*"/>
<!-- 排除注解Controller -->
< context:exclude-filter type= "annotation" expression ="org.springframework.stereotype.Controller"/>
</context:component-scan>
Filter Type | Examples Expression | Description |
annotation | org.example.SomeAnnotation | 符合SomeAnnoation的target class |
assignable | org.example.SomeClass | 指定class或interface的全名 |
aspectj | org.example..*Service+ | AspectJ語法 |
regex | org.example.Default.* | Regelar Expression |
custom | org.example.MyTypeFilter | Spring3新增自訂Type,實作 org.springframework.core.type.TypeFilter |