包含多个`context:exclude-filter`s的正确语法是什么?

时间:2011-07-05 14:16:20

标签: java spring spring-mvc aspectj

包含多个context:exclude-filter的正确语法是什么?

我正在使用它,但我不知道它是否有效:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:annotation-config />
    <context:component-scan base-package="com.myapp">
        <context:exclude-filter type="aspectj" expression="com.myapp.components.*"/>
        <context:exclude-filter type="aspectj" expression="com.myapp.batch.*"/>
        <context:exclude-filter type="aspectj" expression="com.myapp.widgets.*"/>
        <context:exclude-filter type="aspectj" expression="com.myapp.tools.*"/>
    </context:component-scan>

    <import resource="applicationContext-data.xml" />
    <import resource="applicationContext-security.xml" />
    <import resource="applicationContext-service.xml" />

</beans>

1 个答案:

答案 0 :(得分:3)

您可以指定多个包含和排除。您还可以使用regex等过滤器在一个表达式中捕获多个包。看一下规范:http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch04s12.html