在错误:: 0找不到引用切入点注解 [英] error at ::0 can't find referenced pointcut annotation

查看:759
本文介绍了在错误:: 0找不到引用切入点注解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个方面,监测的某些方法的时间执行。当我试图运行测试,我得到这个错误:

I am trying to create an aspect to monitor the time execution of certain methods. When I tried to run the test I get this error:

Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut annotation
    at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:301)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207)

当ApplicationContext需要载入。

when the ApplicationContext is loading.

我定义注释为:

@Retention(RetentionPolicy.RUNTIME)
@Target(
{
    ElementType.METHOD, 
    ElementType.TYPE
})
public @interface TimePerformance {

}

这是纵横code:

And this is the aspect code:

@Aspect
public class MonitorImpl{

    private static final Log LOG = LogFactory.getLog(MonitorImpl.class);


    @Pointcut(value="execution(public * *(..))")
    public void anyPublicMethod() { }



    @Around("anyPublicMethod() && annotation(timePerformance)")
    public Object  timePerformance(ProceedingJoinPoint pjp,TimePerformance timePerformance) throws Throwable {

        if (LOG.isInfoEnabled()) {
             LOG.info("AOP - Before executing "+pjp.getSignature());
        }

        Long startTime = System.currentTimeMillis();

        Object result = pjp.proceed();

        Long stopTime = System.currentTimeMillis();

        LOG.info("MONITOR TIME_EXECUTION "+pjp.getSignature()+" : "+(stopTime-startTime));

        if (LOG.isInfoEnabled()) {
             LOG.info("AOP - After  executing "+pjp.getSignature());
        }

        return result;

    }


}

和配置是:

<!-- AOP support -->
<bean id='stateAspectImpl' class='eu.genetwister.snpaware.ui.aspect.StateAspectImpl' />
 <bean id='monitorImpl' class='eu.genetwister.snpaware.monitor.MonitorImpl' />
<aop:aspectj-autoproxy>
    <aop:include name='stateAspectImpl' />
     <aop:include name='monitorImpl' />
</aop:aspectj-autoproxy>

我刚刚查了很多问题在这里,但其中大多数给出的解决方案中使用的AspectJ的1.7版本。我使用的:

I just checked many questions here, but most of them gives as solution use the version 1.7 of aspectj. I am using:

 <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.7.0</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.7.0</version>
    </dependency>

其他的解决方案,点在方法签名变量的名字,但你可以看到没有错误这一点。

Other solution point to the name of the variable in the method signature, but as you can see there is no error on that.

有谁在哪里的问题任何想法?

Does anyone any idea about where is the problem?

感谢

推荐答案

我解决了切面类使用这个配置的问题。

I solve the problem using this configuration in the aspect class

@Around("execution(* *(..)) && @annotation(timePerformance)")
public Object  timePerformance(ProceedingJoinPoint pjp, TimePerformance timePerformance) throws Throwable 

但是,现在的问题,没有被执行的一个方面。

But the problem now, the aspect is not being executed.

这篇关于在错误:: 0找不到引用切入点注解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆