用例子直接说明:

<?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
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-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<bean id="arithmeticCalculator" class="com.jeremy.aop.xml.ArithmeticCalculatorImpl"></bean> <!-- 第一步配置Bean,因为切面也是一个Bean -->
<bean id="loggingAspect" class="com.jeremy.aop.xml.LoggingAspect"></bean> <!-- 第二部配置AOP -->
<aop:config>
<!-- 第三步配置切面使用的表达式 -->
<aop:pointcut expression="execution(* com.jeremy.aop.xml.ArithmeticCalculator.*(..))" id="pointcut"/>
<!-- 第四步配置切面,指定切面类 -->
<aop:aspect ref="loggingAspect">
<!-- 第五步配置通知 -->
<aop:before method="beforeMethod" pointcut-ref="pointcut"/>
<aop:after method="afterMethod" pointcut-ref="pointcut"/>
<!-- returning:代表返回的值,记得要和通知的方法哪个参数保持一致,其实跟注解一样的,注解的本质就是基于xml配置的 -->
<aop:after-returning method="AfterReturning" pointcut-ref="pointcut" returning="result"/>
<!-- e:代表着要传递的异常 -->
<aop:after-throwing method="AfterThrowing" pointcut-ref="pointcut" throwing="e"/> </aop:aspect>
</aop:config> <bean id="validateAspect" class="com.jeremy.aop.xml.validateAspect"></bean> </beans>

基于xml文件的格式配置Spring的AOP的更多相关文章

  1. Spring中Bean的配置:基于XML文件的方式

    Bean的配置一共有两种方式:一种是基于XML文件的方式,另一种是基于注解的方式.本文主要介绍基于XML文件的方式 <bean id="helloWorld" class=& ...

  2. Spring框架入门之基于xml文件配置bean详解

    关于Spring中基于xml文件配置bean的详细总结(spring 4.1.0) 一.Spring中的依赖注入方式介绍 依赖注入有三种方式 属性注入 构造方法注入 工厂方法注入(很少使用,不推荐,本 ...

  3. 7 -- Spring的基本用法 -- 11... 基于XML Schema的简化配置方式

    7.11 基于XML Schema的简化配置方式 Spring允许使用基于XML Schema的配置方式来简化Spring配置文件. 7.11.1 使用p:命名空间简化配置 p:命名空间不需要特定的S ...

  4. java struts2入门学习--基于xml文件的声明式验证

    一.知识点总结 后台验证有两种实现方式: 1 手工验证顺序:validateXxx(针对Action中某个业务方法验证)--> validate(针对Action中所有的业务方法验证) 2 声明 ...

  5. 【MyBatis学习05】SqlMapConfig.xml文件中的配置总结

    经过上两篇博文的总结,对mybatis中的dao开发方法和流程基本掌握了,这一节主要来总结一下mybatis中的全局配置文件SqlMapConfig.xml在开发中的一些常用配置,首先看一下该全局配置 ...

  6. 读取xml文件中的配置参数实例_java - JAVA

    文章来源:嗨学网 敏而好学论坛www.piaodoo.com 欢迎大家相互学习 paras.xml文件 <?xml version="1.0" encoding=" ...

  7. MyEclipse/Eclipse中XML文件的格式化配置

    Eclipse中XML文件的格式化配置 MyEclipse: 这一步的配置是使格式化的效果为控件的每个属性配置占一行.进入 Window/Preferences,展开到 XML/XML Resourc ...

  8. 基于xml文件实现系统属性配置管理

    文章标题:基于xml文件实现系统属性配置管理 . 文章地址: http://blog.csdn.net/5iasp/article/details/11774501 作者: javaboy2012 E ...

  9. maven的setting.xml文件中只配置本地仓库路径的方法

    maven的setting.xml文件中只配置本地仓库路径的方法 即:settings标签下只有一个 localRepository标签,其他全部注释掉即可 <?xml version=&quo ...

随机推荐

  1. 【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)

    [CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per t ...

  2. atitit. 研发管理---如何根据自己的特挑选 产业、行业、职业、岗位与自己发展的关系

    atitit. 研发管理---如何根据自己的特挑选 产业.行业.职业.岗位与自己发展的关系 1. 产业及分类 1 2. 二.行业 2 3. 职业概念- 3 4. 职业划分 3 5. 职业兴趣分类 4 ...

  3. MongoDB Query 的几个方法

    Query.All("name", "a", "b");//通过多个元素来匹配数组Query.And(Query.EQ("name ...

  4. CConfig类

    #ifndef __CONFIG_H__ #define __CONFIG_H__ #include "GameFrameHead.h" //图片信息 struct ImageIn ...

  5. trk压力测试工具(测试tcp)

    wrk 是web站点压力测试工具 针对tcp协议的压力测试工具,没有找到合适的. 自己写一个,起名 trk.

  6. love2d教程30--文件系统

    在游戏里少不了文件操作,在love2d里我们可以直接用lua自带的io函数,如果不熟悉可以先读一下我的lua文件读写. 相对lua,love2d提供了更多的函数, 方便我们操作文件.不过可能处于安全考 ...

  7. HashMap原理<转>

    1. HashMap的数据结构 数据结构中有数组和链表来实现对数据的存储,但这两者基本上是两个极端. 数组 数组存储区间是连续的,占用内存严重,故空间复杂的很大.但数组的二分查找时间复杂度小,为O(1 ...

  8. python 神经网络实例

    #http://python.jobbole.com/82758/ # import numpy as np # # # # sigmoid function # def nonlin(x, deri ...

  9. 【转】【Linux】Linux 下zip包的压缩与解压

    linux zip 命令详解 功能说明:压缩文件. 语 法:zip [-AcdDfFghjJKlLmoqrSTuvVwXyz$][-b <工作目录>][-ll][-n <字尾字符串& ...

  10. Android不同版本下Notification创建方法

    项目环境 Project Build Target:Android 6.0 问题: 使用 new Notification(int icon, CharSequence tickerText, lon ...