Announcement Announcement Module
Collapse
No announcement yet.
compile error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • compile error

    I use Spring Tool Suite 3.1.0 to create a spring project,and I put following jar into classpath
    org.springframework.asm_3.1.1.RELEASE.jar
    org.springframework.beans_3.1.1.RELEASE.jar
    org.springframework.context.support_3.1.1.RELEASE. jar
    org.springframework.context_3.1.1.RELEASE.jar
    org.springframework.core_3.1.1.RELEASE.jar
    org.springframework.aop_3.1.1.RELEASE.jar

    Then I write following two code:
    Code:
    package com.apress.prospring3.ch7.cflow;
    import java.lang.reflect.Method;
    import org.springframework.aop.MethodBeforeAdvice;
    public class SimpleBeforeAdvice implements MethodBeforeAdvice{
     @Override 
     public void before(Method method, Object[] arg1, Object arg2)
       throws Throwable {
      // TODO Auto-generated method stub
      System.out.println("Before method: "+method);
     }
    }
    Code:
    package com.apress.prospring3.ch7.cflow;
    import org.springframework.aop.Advisor;
    import org.springframework.aop.Pointcut;
    import org.springframework.aop.framework.ProxyFactory;
    import org.springframework.aop.support.ControlFlowPointcut;
    import org.springframework.aop.support.DefaultPointcutAdvisor;
    public class ControlFlowExample {
     public static void main(String[] args){
      ControlFlowExample ex=new ControlFlowExample();
      ex.run();  
     }   
     public void run(){ 
      TestBean target=new TestBean();
      Pointcut pc=new ControlFlowPointcut(ControlFlowExample.class,"test");
      Advisor advisor=new DefaultPointcutAdvisor(pc,new SimpleBeforeAdvice());
      ProxyFactory pf=new ProxyFactory();
      pf.setTarget(target);
      pf.addAdvisor(advisor);
      TestBean proxy=(TestBean)pf.getProxy();
      System.out.println("Trying normal invoke");
      proxy.foo();
      System.out.println("Trying under ControlFlowExample.test()");
      test(proxy);
     }
     private void test(TestBean bean){
      bean.foo();
     }
    }
    Above two code can't compile,the error of SimpleBeforeAdvice is follows:
    Multiple markers at this line
    - The hierarchy of the type SimpleBeforeAdvice is
    inconsistent
    - Breakpoint:SimpleBeforeAdvice

    the error of ControlFlowExample is follows:
    Multiple markers at this line
    - Line breakpoint:ControlFlowExample [line: 17] - run()
    - The constructor DefaultPointcutAdvisor(Pointcut, SimpleBeforeAdvice) is
    undefined

    Why I can't compile above code? Missing jar file? How to make above code to run?
    Thanks
Working...
X