Spring 3 to Spring 4 (Java 7 to Java 8) - AspectJ compilation error : "cannot access ApplicationEventPublisherAware"
Spring 3 to Spring 4 (Java 7 to Java 8) - AspectJ compilation error : "cannot access ApplicationEventPublisherAware"
我正在将一个项目从 Java 7 升级到 Java 8(同时将 Spring 3 升级到 Spring 4)。
我收到以下编译错误:
DomainSecurityAspect.java:[88,39] error: cannot access ApplicationEventPublisherAware
它抱怨的代码是:
@Around("target(com.mycompany.automation.domain.framework.DomainEntityImpl+) && !execution(* equals(..)) && !execution(* hashCode()) "
+ "&& !execution(* toString()) && !execution(* get*(..)) && !execution(* is*(..)) && execution(public * *(..)) "
+ "&& !within(com.mycompany.iecc.data.automation.domain.aop.DomainSecurityAspect)"
+ "&& !execution(* com.mycompany.iecc.data.automation.domain.framework.BaseObject.*(..))"
+ "&& !execution(* com.mycompany.iecc.data.automation.domain.framework.DomainObjectImpl.*(..))")
public Object domainObjectInstanceExecution(final ProceedingJoinPoint thisJoinPoint) throws Throwable
{
if (this.securityInterceptor == null)
{
return thisJoinPoint.proceed();
}
final AspectJCallback callback = new AspectJCallback()
{
@Override
public Object proceedWithObject()
{
try
{
return thisJoinPoint.proceed();
}
catch (Error e)
{
throw e;
}
catch (RuntimeException re)
{
throw re;
}
catch (Throwable th)
{
throw new RuntimeException(th);
}
}
};
// Compiler complains about this line
return this.securityInterceptor.invoke(thisJoinPoint, callback);
}
我使用的软件版本:
Java8(jdk1.8.0_66)
Spring 4.2.4.RELEASE
Aspectj 版本 1.8.8
cglib-nodep 版本 3.2.0
注意:当它使用 Java 7 和 Spring 4 时编译正常,但是当使用 Java 8 编译时它会给出编译错误。
事实证明错误是在我的 POM 中——为了解决这个问题,我不得不将范围从 runtime 更改为 compile
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>compile</scope>
</dependency>
我正在将一个项目从 Java 7 升级到 Java 8(同时将 Spring 3 升级到 Spring 4)。
我收到以下编译错误:
DomainSecurityAspect.java:[88,39] error: cannot access ApplicationEventPublisherAware
它抱怨的代码是:
@Around("target(com.mycompany.automation.domain.framework.DomainEntityImpl+) && !execution(* equals(..)) && !execution(* hashCode()) "
+ "&& !execution(* toString()) && !execution(* get*(..)) && !execution(* is*(..)) && execution(public * *(..)) "
+ "&& !within(com.mycompany.iecc.data.automation.domain.aop.DomainSecurityAspect)"
+ "&& !execution(* com.mycompany.iecc.data.automation.domain.framework.BaseObject.*(..))"
+ "&& !execution(* com.mycompany.iecc.data.automation.domain.framework.DomainObjectImpl.*(..))")
public Object domainObjectInstanceExecution(final ProceedingJoinPoint thisJoinPoint) throws Throwable
{
if (this.securityInterceptor == null)
{
return thisJoinPoint.proceed();
}
final AspectJCallback callback = new AspectJCallback()
{
@Override
public Object proceedWithObject()
{
try
{
return thisJoinPoint.proceed();
}
catch (Error e)
{
throw e;
}
catch (RuntimeException re)
{
throw re;
}
catch (Throwable th)
{
throw new RuntimeException(th);
}
}
};
// Compiler complains about this line
return this.securityInterceptor.invoke(thisJoinPoint, callback);
}
我使用的软件版本:
Java8(jdk1.8.0_66)
Spring 4.2.4.RELEASE
Aspectj 版本 1.8.8
cglib-nodep 版本 3.2.0
注意:当它使用 Java 7 和 Spring 4 时编译正常,但是当使用 Java 8 编译时它会给出编译错误。
事实证明错误是在我的 POM 中——为了解决这个问题,我不得不将范围从 runtime 更改为 compile
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>compile</scope>
</dependency>