[英]Spring AOP: Advice not executing for method with custom annotation
我創建了一個自定義注釋:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface ValidateBeforeBuild {
}
一個方面是:
@Aspect
@Component
public class AspectForBuildInBuilders {
private static final Logger LOGGER = LoggerFactory.getLogger(AspectForBuildInBuilders.class);
@Before("@annotation(validateBeforeBuild )")
public void validateBusinessModelAdvice(JoinPoint jp, ValidateBeforeBuild validateBeforeBuild ) throws Throwable {
LOGGER.info("Executing class: {}", jp);
}
}
我有一個標有上面注釋的build()
。 當我嘗試調用build()
,我沒有從validateBusinessModelAdvice()
獲取日志消息。 我在其中一個配置類中也有@EnableAspectJAutoProxy
。 我錯過了什么嗎? 是否還需要更多信息?
您將注釋定義為ValidateBeforeBuild
並在您指定的validateBeforeBuild
方面(注意注釋中的上部V
)
嘗試改變
@Before("@annotation(validateBeforeBuild)")
對於
@Before("@annotation(ValidateBeforeBuild)")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.