spring2.0 AOP

和Spring1.X相比,Spring2.X使用AspectJ的语法来声明AOP,这使得它更“标准”,更灵活了。

AspectJ的配置方法有二种:

一种是在applicationContext.xml中配置

java 代码
  1. "1.0" encoding="UTF-8"?>    在使用Spring的AOP编程时,会用到这几个lib:
    asm-2.2.2.jar
    asm-commons-2.2.2.jar
    asm-util-2.2.2.jar

    Hibernate使用如果lib:
    asm.jar
    asm-attrs.jar


    其中asm-2.2.2.jar与asm.jar存在类上的冲突!!!
    使用其中之一或两者都使用,可能会出现如下错误:
    java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor
    java.lang.NoClassDefFoundError: org/objectweb/asm/commons/EmptyVisitor
    java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit。。。。。。


    解决办法是:
    1.去掉类路径上的关于Hibernate的3个lib
    asm.jar
    asm-attrs.jar
    cglib-2.1.3.jar

    2.加入Spring中的以下4个lib
    asm-2.2.2.jar
    asm-commons-2.2.2.jar
    asm-util-2.2.2.jar
    cglib-nodep-2.1_3.jar
  2. "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:tx="http://www.springframework.org/schema/tx"  
  6.     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd  
  7.            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd  
  8.            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"  
  9.     default-autowire="byName" default-lazy-init="true">   
  10.   
  11.        
  12.     "propertyConfigurer"  
  13.         class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">   
  14.         "locations">   
  15.              <list></list>   
  16.                 <value></value>classpath*:config/jdbc.properties   
  17.                 <value></value>classpath*:config/hibernate.properties   
  18.                 <value></value>classpath*:config/mail.properties   
  19.                
  20.            
  21.        
  22.   
  23.        
  24.        
  25.   
  26.        
  27.        
  28.   
  29.        
  30.        
  31.         <aop:advisor span=""> </aop:advisor>
  32.             pointcut="execution(* org.springside.core.dao.*Dao.*(..))"  
  33.             advice-ref="txAdvice" />           
  34.     
  35.   
  36.        
  37.        
  38.         <tx:attributes>   </tx:attributes>   
  39.             
  40.             
  41.             
  42.         
  43.     
  44.        
  45.     <aop:config>   </aop:config>   
  46.            
  47.             ref="workflowHistoryImpl">   
  48.             
  49.                 expression="execution(* cn.grgbanking.view..*Impl.saveData(..)) and args(request)" />   
  50.             
  51.                 method="saveHistory" />   
  52.         
  53.     
  54.   
  55.     "workflowHistoryImpl"  
  56.         class="cn.grgbanking.wfms.impl.WorkflowHistoryImpl">   
  57.        
  58.   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值