例子下载

  对于xml的AOP配置主要集中在配置文件中,所以只要设置好配置文件就行了

beans.xml

<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<context:annotation-config />
<context:component-scan base-package="com.bjsxt"/> <bean id="logInterceptor" class="com.bjsxt.aop.LogInterceptor"></bean>
<aop:config>
<aop:pointcut expression="execution(public * com.bjsxt.service..*.add(..))" id="logService"/>
<aop:aspect id="logAspect" ref="logInterceptor">
<aop:before method="before" pointcut-ref="logService" />
</aop:aspect>
</aop:config>
</beans>

程序运行时先会查看aop:pointcut里面的expression,如果调用的方法在此里面,则调用相应的切面。

上面总括的意思为:程序在调用com.bjsxt.service包下面的add方法或子包等下面add方法(任意参数)时,先调用com.bjsxt.aop.LogInterceptor里面的before方法。

spring_AOP_XML的更多相关文章

随机推荐

  1. 基于多进程的Tcp套接字服务器

    服务端 import socketfrom multiprocessing import Process def task(c): print('顾客吃点啥') while True: data = ...

  2. Android源码分析一 Android系统架构

    一 Android系统架构 Linux内核层(Linux Kernel):Android系统基于Linux2.6内核,这一层为Android设备各种硬件提供了底层驱动,如显示驱动.音频驱动.照相机驱动 ...

  3. redis客户端、分布式锁及数据一致性

    Redis Java客户端有很多的开源产品比如Redission.Jedis.lettuce等. Jedis是Redis的Java实现的客户端,其API提供了比较全面的Redis命令的支持:Redis ...

  4. svn上check下来的项目,用idea打开,菜单栏没有svn工具解决办法

    1.用idea打开你的项目(idea已经配置过小乌龟了) 2.菜单栏点击VCS,Enable Version Control Integration... 3.选择Subversion 4.这时候,菜 ...

  5. Git使用一:git客户端安装与创建用户

    1.下载并安装Git和图形客户端TortoiseGit Git官网:https://gitforwindows.org/ TortoiseGit官网: https://tortoisegit.org/ ...

  6. linux添加自定义命令

    想添加一个命令, 比如我输入 cdms 按回车, 然后就执行了: cd /mnt/gopath/src/test/app/ 这条命令方法: vi /etc/bashrc 在文件末尾添加 alias c ...

  7. 繁简字转换(C#)

    1.首先引入: using Microsoft.VisualBasic; 2.转换方法: //繁体转简体 public static string Traditional2Simplified(str ...

  8. JAVA 程序编译过程;编辑器,编译器和解释器

    最基本的软件工具包括,编辑器,编译器,解释器; 编译器:编译器就是将一种编程语言代码翻译成另一种语言的等效代码程序. 解释器:解释器将编译和执行交织在一起,即编译一部分代码后执行该部分代码,然后再编译 ...

  9. HDU 1247 Hat’s Words(字典树活用)

    Hat's Words Time Limit : 2000 / 1000 MS(Java / Others)    Memory Limit : 65536 / 32768 K(Java / Othe ...

  10. vsftp日志xferlog格式分析

    vsftp日志xferlog格式分析 [日期:2014-06-25] 来源:Linux社区  作者:Linux [字体:大 中 小]   1.开始vsftp记录日志.修改/etc/vsftpd/vsf ...