基于xml文件的格式配置Spring的AOP
用例子直接说明:
<?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的更多相关文章
- Spring中Bean的配置:基于XML文件的方式
Bean的配置一共有两种方式:一种是基于XML文件的方式,另一种是基于注解的方式.本文主要介绍基于XML文件的方式 <bean id="helloWorld" class=& ...
- Spring框架入门之基于xml文件配置bean详解
关于Spring中基于xml文件配置bean的详细总结(spring 4.1.0) 一.Spring中的依赖注入方式介绍 依赖注入有三种方式 属性注入 构造方法注入 工厂方法注入(很少使用,不推荐,本 ...
- 7 -- Spring的基本用法 -- 11... 基于XML Schema的简化配置方式
7.11 基于XML Schema的简化配置方式 Spring允许使用基于XML Schema的配置方式来简化Spring配置文件. 7.11.1 使用p:命名空间简化配置 p:命名空间不需要特定的S ...
- java struts2入门学习--基于xml文件的声明式验证
一.知识点总结 后台验证有两种实现方式: 1 手工验证顺序:validateXxx(针对Action中某个业务方法验证)--> validate(针对Action中所有的业务方法验证) 2 声明 ...
- 【MyBatis学习05】SqlMapConfig.xml文件中的配置总结
经过上两篇博文的总结,对mybatis中的dao开发方法和流程基本掌握了,这一节主要来总结一下mybatis中的全局配置文件SqlMapConfig.xml在开发中的一些常用配置,首先看一下该全局配置 ...
- 读取xml文件中的配置参数实例_java - JAVA
文章来源:嗨学网 敏而好学论坛www.piaodoo.com 欢迎大家相互学习 paras.xml文件 <?xml version="1.0" encoding=" ...
- MyEclipse/Eclipse中XML文件的格式化配置
Eclipse中XML文件的格式化配置 MyEclipse: 这一步的配置是使格式化的效果为控件的每个属性配置占一行.进入 Window/Preferences,展开到 XML/XML Resourc ...
- 基于xml文件实现系统属性配置管理
文章标题:基于xml文件实现系统属性配置管理 . 文章地址: http://blog.csdn.net/5iasp/article/details/11774501 作者: javaboy2012 E ...
- maven的setting.xml文件中只配置本地仓库路径的方法
maven的setting.xml文件中只配置本地仓库路径的方法 即:settings标签下只有一个 localRepository标签,其他全部注释掉即可 <?xml version=&quo ...
随机推荐
- ubuntu16.04安装jekyll 3.3.1
本次安装的ekyll为最新的3.3.1版本. 一.预备工作,因位jekyll需要很多软件的支持,所以准备工作要做足. Ruby (including development headers, v1.9 ...
- fromdata上传数据
使用formdata上传数据 $(function() { fileStack=[];//总的上传图片栈 //上传事件 $("#uploadBtn").on("click ...
- 百度地图 JSAPI使用 mark 定位地址 与周边覆盖物
http://lbsyun.baidu.com/index.php?title=jspopular api http://developer.baidu.com/map/jsdemo.htm#a ...
- python将str转换成字典
典型的应用场景:Json数据的解析 >>> user "{'name' : 'jim', 'sex' : 'male', 'age': 18}" >> ...
- dp之完全背包poj3181(高精度背包)
这个题目要用到大数的加法,其他的,我没有感觉到有什么难想的......比较水的背包题,掠过..... #include<iostream> #include<stdio.h> ...
- 后缀数组LCP + 二分 - UVa 11107 Life Forms
Life Forms Problem's Link Mean: 给你n个串,让你找出出现次数大于n/2的最长公共子串.如果有多个,按字典序排列输出. analyse: 经典题. 直接二分判断答案. 判 ...
- json剥离
String json=get("http://www.weather.com.cn/data/cityinfo/101010100.html"); JSONObject json ...
- lmbench
lmbench作为性能检测工具的一种,提供内存,网络,内核等多方面的测试工具.是benchmark众多功能测试软件中的一种.几天了解了下,记录于此. 参考链接 http://www.bitmover. ...
- 曲线学习PyQt5方案一
PyQt5官方网站没直接给出API,这个很操蛋啊. PtQt4官方网站有完整的API,C++版本的Qt5也能找到完整的API资料.由于Qt5的C++和Python3的类和函数实现应该是一致的,所以可以 ...
- 【DeepLearning】一些资料
记录下,有空研究. http://nlp.stanford.edu/projects/DeepLearningInNaturalLanguageProcessing.shtml http://nlp. ...