基于XML的Spring AOP配置
来源:互联网 发布:vmware tools linux 编辑:程序博客网 时间:2024/05/03 03:40
Spring AOP的配置可以基于注解,也可以基于XML文件。前面几篇都是使用注解的方式。下面介绍下使用XML文件如何配置
使用的测试类和切面类都类似。只需要属于AOP的注解去掉即可。下面是AOP的XML配置:
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xmlns:aop="http://www.springframework.org/schema/aop" 5 xmlns:context="http://www.springframework.org/schema/context" 6 xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd 7 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 8 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> 9 10 <!-- 配置bean -->11 <bean id="arithmeticCalculator" class="com.yl.spring.aop.xml.ArithmeticCalculatorImpl"></bean>12 13 14 <!-- 配置切面的bean -->15 <bean id="loggingAspect" class="com.yl.spring.aop.xml.LoggingAspect"></bean>16 17 <bean id="validationAspect" class="com.yl.spring.aop.xml.ValidationAspect"></bean>18 19 <!-- 配置AOP -->20 <aop:config>21 <!-- 配置切点表达式 -->22 <aop:pointcut expression="execution(public int com.yl.spring.aop.xml.ArithmeticCalculator.*(..))" id="pointcut"/>23 <!-- 配置切面及通知 -->24 <aop:aspect ref="loggingAspect" order="2">25 <aop:before method="beforeMethod" pointcut-ref="pointcut"/>26 <aop:after method="afterMethod" pointcut-ref="pointcut"/>27 <aop:after-throwing method="afterThrowing" pointcut-ref="pointcut" throwing="e"/>28 <aop:after-returning method="afterReturning" pointcut-ref="pointcut" returning="result"/>29 30 <aop:around method="aroundMethod" pointcut-ref="pointcut"/>31 </aop:aspect>32 33 <aop:aspect ref="validationAspect" order="1">34 <aop:before method="vlidateArgs" pointcut-ref="pointcut"/>35 </aop:aspect>36 </aop:config>37 38 </beans>
0 0
- 基于XML的spring AOP配置
- Spring的AOP配置(基于xml)
- Spring -- 基于XML的AOP通知配置
- 基于XML的Spring AOP配置
- Spring基于XML配置AOP
- Spring的AOP基于xml常用的几种配置
- Spring中AOP基于XML的两种配置方法
- 基于XML配置的纯POJO Spring 2.x Aop
- Spring 基于XML配置的AOP入门案例
- Spring AOP(3)基于XML配置实现的示例
- Spring AOP基于XML配置的管理方式
- Spring AOP(3)基于XML配置实现的示例
- spring学习总结(十):基于 XML 的配置AOP
- Spring基于xml文件的方式配置AOP
- Spring AOP---基于Xml配置应用demo
- spring添加AOP切面-基于XML配置
- spring-aop基于xml文件配置
- Spring实现AOP方式之一:基于XML配置的Spring AOP
- 【iOS】iOS开发视图跳转:利用storyboard简单实现视图的跳转与返回
- HTML学习-网页主体标记body(一)
- universalimageloader uil doesn't support scheme(protocol
- Objective-C 【protocol-协议 的了解使用】
- 编译cloog for gcc 4.8.5 问题
- 基于XML的Spring AOP配置
- 1010--注解Annotation
- 数据结构之自建算法库——顺序表
- SVN学习笔记1 -- 为什么要使用SVN
- SharePoint 2010商业智能组件
- Qt5.2 for Android 配置及部署到手机运行
- php利用smtp类轻松的发送电子邮件
- Bubble Cup 8 - Finals [Online Mirror] - A.Fibonotci【分段+ST表】
- codeforce 568A Primes or Palindromes?