0

注解:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface IbatisAnno {}

方面:

@Component
@Aspect
public class IbatisAsepct {
    
    //not works
    @Pointcut("@annotation(xxx.IbatisAnno)")
    public void m(){}

    //works
    @Pointcut("execution(* xxx.xxDAO.*(..))")
    public void m2(){}

    @Before("m()")
    public void testM(){
        System.out.println("Before   Method...............");
    }


    @Before("m2()")
    public void testM2(){
        System.out.println("Before   Method2...............");
    }
}

目标类:

@EnableAspectJAutoProxy()
public class IbatisOfferFeedDAO extends SqlMapClientDaoSupport implements OfferFeedDAO{
   @IbatisAnno
   public void xxx(){
      this.getSqlMapClientTemplate().insert();
   }
}

Aspect 在使用时不生效@Pointcut("@annotation(xxx.IbatisAnno)"),但在使用时有效@Pointcut("execution(* xxx.xxDAO.*(..))")

4

0 回答 0