国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Spring AOP--基于XML文件的配置

2019-11-14 21:55:17
字體:
來源:轉載
供稿:網友
SPRing AOP--基于xml文件的配置

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>


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南昌市| 揭西县| 大悟县| 普定县| 阿巴嘎旗| 潮州市| 邯郸市| 宁夏| 南华县| 郑州市| 工布江达县| 沛县| 宜都市| 伊金霍洛旗| 龙南县| 绵阳市| 桃园市| 罗城| 和顺县| 巴彦淖尔市| 岳西县| 揭西县| 包头市| 桓仁| 安吉县| 马边| 太谷县| 宜阳县| 柳州市| 裕民县| 务川| 凤庆县| 资讯 | 岳西县| 炎陵县| 迁西县| 科技| 龙山县| 科技| 襄汾县| 渑池县|