基于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 ...
随机推荐
- ui-router详解(二)ngRoute工具区别
我们了解 angular.js 是一种富客户端单页面应用,所以要在一个页面呈现不同的视图,路由起到了至关重要的作用. angular.js 为我们封装好了一个路由工具 ngRoute ,它是一种靠ur ...
- 632. Binary Tree Maximum Node【Naive】
Find the maximum node in a binary tree, return the node. Example Given a binary tree: 1 / \ -5 2 / \ ...
- FreeRTOS基础知识
前面一篇文章介绍了一些命名规范之类的基础知识,但是我觉得还缺少一定前言知识,就是裸机和操作系统有什么区别,为什么我们需要学freertos,因为招聘要求?那么为什么招聘网又会有这个要求呢?所以我们为什 ...
- 基于jQuery实现文字倾斜显示代码
这是一款基于jQuery实现文字倾斜显示,这是一款基于jQuery实现的超酷动态文字显示效果.适用浏览器:IE8.360.FireFox.Chrome.Safari.Opera.傲游.搜狗.世界之窗. ...
- 获取页面的checkbox,并给参数赋值
需求: 需要发送的请求:
- Unix系统编程()文件控制操作fcntl
fcntl系统调用对一个打开的文件描述符执行一系列的控制操作. int fcntl(int fd, int cmd, -) cmd参数所支持的操作范围很广 fcntl的第三个参数以省略号表示,意味着可 ...
- 华为/中兴 3G 模块的调试
1 检查/etc/init.d/pppd『红颜色的使上电自动上网注册(如果没有红颜色的语句),请添加』 #!/bin/sh#DAEMON=/usr/sbin/pppdPIDFILE=/var/run/ ...
- ps aux|awk -F'[ ]+' '$3>90{print $2}'|xargs -n1 kill -9
ps aux|awk -F'[ ]+' '$3>90{print $2}'|xargs -n1 kill -9
- keep learning
fueling people’s creativity 助长了人们的创造力,燃烧了人们的激情
- alert的美化
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...