我正在使用 spring-boot-starter-parent 2.0.3-RELEASE,在我的方面使用切入点原语“get”,如下所示。
@Pointcut("get(* *) && @annotation(com.test.cryptography.EncryptEnabled)")
public void getEncryptedValue() {
}
但是当我将 Spring Boot 版本升级到 2.6.6 时,它开始失败并出现以下错误。
BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException: Pointcut expression 'getEncryptedValue()' contains unsupported pointcut primitive 'get'
对于最新的春季版本我需要做任何更改吗
如 Spring 手册中所述,支持的切入点指示符一章,
get()
在 Spring AOP 中不可用。也就是说,如果它以前对您有用,那么您必须使用过原生 AspectJ,可能通过 LTW(加载时编织)。
因此,如果在您的 Spring(Boot)升级后它不再工作,您可能只是遇到了配置问题,也许很简单,比如忘记重新添加 JMV 参数
-javaagent:/path/to/aspectjweaver.jar
,这可能是您之前使用过的。