如题,我是用的事Spring的使用AspectJ表达式的Schema配置方法
配置文件如下:public class AspectJProxyTest { /**
 * @param args
 */
public static void main(String[] args) {
String config = "llh/aop/schema/applicationContextSc.xml";
ApplicationContext ctx = 
new ClassPathXmlApplicationContext(config);

Waiter naiveWaiter = ctx.getBean("naiveWaiter",Waiter.class);
naiveWaiter.greetTo("LLH");

}}
配置文件如下<?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:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd"><aop:config proxy-target-class="false">
<aop:aspect ref="adviceMethods">
<aop:before method="beforeGreeting" pointcut="target(llh.aop.schema.NaiveWaiter) and execution(* greeTo(..))"/>
</aop:aspect>
</aop:config><bean id="adviceMethods" class="llh.aop.schema.PreGreetingAspect"/>
<bean id="naiveWaiter" class="llh.aop.schema.NaiveWaiter"/>
</beans>控制台输出结果就只有NaiveWaiter:greet to LLH...并没有之前所期望的How are you的输出,请问是怎么回事.谢谢
SpringAOPSchemaAspectJ

解决方案 »

  1.   

    这应该是比较基础的问题了吧,只要配好spring就行呗,你的方法 greetTo()怎么写的看看
      

  2.   

    把该贴的都贴出来吧 advice的相关代码
      

  3.   

    我有一个接口package llh.aop.schema;/**
     * @author L.H
     *
     */
    public interface Waiter {
    public abstract void greetTo(String clientname);
    public abstract void serveTo(String clientname);
    }
    实现该接口的实体类package llh.aop.schema;public class NaiveWaiter implements Waiter { @Override
    public void greetTo(String clientname) {
    System.out.println("NaiveWaiter:greet to "+clientname+"...");

    } @Override
    public void serveTo(String clientname) {
    System.out.println("NaiveWaiter:serving to "+clientname+"...");

    }

    }
    增强的一个pojopublic class PreGreetingAspect {

    public void beforeGreeting(){
    System.out.println("How are you");
    }
    }
      

  4.   

    贴出来了,在后面。spring应该配置好的
      

  5.   

    自己结帖吧,and后头不能有空格.晕死我了