读书人

AOP切不了,该怎么处理

发布时间: 2012-03-26 15:46:55 作者: rapoo

AOP切不了

Java code
<?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"    xsi:schemaLocation="http://www.springframework.org/schema/beans           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd           http://www.springframework.org/schema/aop           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">    <bean id="sr" class="com.springmodel.Shiren" />    <bean id="qs" class="com.springmodel.Qishi">    </bean>        <aop:config>        <aop:aspect ref="sr" >            <aop:pointcut id="qeMethod" expression="execution(* com.springmodel.Qishi.tanXian(*))" />            <aop:before method="singBefore" pointcut-ref="qeMethod"/>            <aop:after method="singAlter" pointcut-ref="qeMethod"/>        </aop:aspect>    </aop:config></beans>



Java code
package com.springmodel;public class Shiren {    public void singBefore(){        System.out.println("探险之前sing");    }    public void singAlter(){        System.out.println("探险之后sing");    }}


程序能够运行成功过,但是这2条语句
Java code
<aop:before method="singBefore" pointcut-ref="qeMethod"/>            <aop:after method="singAlter" pointcut-ref="qeMethod"/>


运行没有效果

[解决办法]
晕,怎么看不见哦。
<aop:pointcut id="qeMethod" expression="execution(* com.springmodel.Qishi.tanXian(*))" />
这个导致的,改成
<aop:pointcut id="qeMethod" expression="execution(* com.springmodel.Qishi.tanXian(..))" />或者
<aop:pointcut id="qeMethod" expression="execution(* com.springmodel.Qishi.tanXian())" />

试试吧

读书人网 >J2EE开发

热点推荐