相关疑难解决方法(0)

在Java 7中使用AspectJ AOP时出错

我已经将Java更新为版本"1.7.0_09-icedtea"(以前它是1.6)并获得以下消息:

Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate be
an class [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: error the 
@annotation pointcut expression is only supported at Java 5 compliance level or above
Run Code Online (Sandbox Code Playgroud)

应用程序已使用java 1.6编译,编译器合规性级别也设置为1.6.我正在使用spring 3.1.0

有没有人能够在Java 7下使用aspectj?

spring aspectj java-7

23
推荐指数
1
解决办法
2万
查看次数

错误在:: 0无法找到引用的切入点注释

我正在尝试创建一个方面来监视某些方法的执行时间.当我尝试运行测试时,我收到此错误:

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)
Run Code Online (Sandbox Code Playgroud)

当ApplicationContext加载时.

我将注释定义为:

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

}
Run Code Online (Sandbox Code Playgroud)

这是方面代码:

@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 = …
Run Code Online (Sandbox Code Playgroud)

java aop spring annotations spring-aop

3
推荐指数
1
解决办法
5902
查看次数

标签 统计

spring ×2

annotations ×1

aop ×1

aspectj ×1

java ×1

java-7 ×1

spring-aop ×1