作用是标记一个切面类(spring不会将切面注册为Bean也不会增强,但是需要扫描)

    1. <!-- 扫描Aspect增强的类 -->
    2. <context:component-scan base-package="">
    3. <context:include-filter type="annotation"
    4. expression="org.aspectj.lang.annotation.Aspect"/>
    5. </context:component-scan>
    6. <!-- 开启@AspectJ注解支持 -->
    7. <aop:aspectj-autoproxy/>
    8. <?xml version="1.0" encoding="UTF-8"?>
    9. <beans xmlns="http://www.springframework.org/schema/beans"
    10. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    11. xmlns:context="http://www.springframework.org/schema/context"
    12. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    13. <!--包扫描--> <context:component-scan base-package="com.cn"/>
    14. <!--开启ioc注解-->
    15. <context:annotation-config/>
    16. <!--开启aop注解-->
    17. <aop:aspectj-autoproxy/>
    18. </beans>