AOP切面编程applicationContext.xml的配置

来源:互联网 发布:军团要塞2 知乎 编辑:程序博客网 时间:2024/05/21 10:33
<?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:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<!-- 配置切面类 -->
<bean id="zhuangbeibean" class="com.gxa.bj.aspect.ZhuangBei"/>
<!-- 配置目标对象类 -->
<bean id="zhangsan" class="com.gxa.bj.service.ZhangSanRole"/>
<bean id="lisi" class="com.gxa.bj.service.LiSiRole"/>
<!-- 配置AOP增强 -->
<aop:config>
<aop:aspect id="zhuangbeiaspect" ref="zhuangbeibean">
<!-- 配置切入点,切入点要满足表达式 -->
<aop:pointcut expression="execution(* com.gxa.bj.service.*.*(..))" id="pointcut"/>
<!-- 要织入增强方法的匹配 -->
<aop:before method="before" pointcut-ref="pointcut"/>
<aop:around method="around" pointcut-ref="pointcut"/>
<aop:after method="after" pointcut-ref="pointcut"/>
</aop:aspect>
</aop:config>
</beans>
0 0
原创粉丝点击