我已经将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?
我正在尝试创建一个方面来监视某些方法的执行时间.当我尝试运行测试时,我收到此错误:
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)