Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 错误位于::0 can';找不到引用的切入点批注_Java_Spring_Annotations_Aop_Spring Aop - Fatal编程技术网

Java 错误位于::0 can';找不到引用的切入点批注

Java 错误位于::0 can';找不到引用的切入点批注,java,spring,annotations,aop,spring-aop,Java,Spring,Annotations,Aop,Spring Aop,我试图创建一个方面来监视某些方法的时间执行。当我尝试运行测试时,出现以下错误: 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.s

我试图创建一个方面来监视某些方法的时间执行。当我尝试运行测试时,出现以下错误:

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时

我将注释定义为:

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

}
这是方面代码:

@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版作为解决方案。我正在使用:

 <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>

org.aspectj
aspectjrt
1.7.0
org.aspectj
aspectjweaver
1.7.0
另一个解决方案指向方法签名中变量的名称,但正如您所看到的,在这方面没有错误

有人知道问题出在哪里吗


谢谢

我在aspect类中使用此配置解决了这个问题

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

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

在切入点的
注释
前面缺少一个
@

@Around("anyPublicMethod() && @annotation(timePerformance)")
                              ^