gpt4 book ai didi

接口(interface)方法定义上的Java注释没有被处理?

转载 作者:行者123 更新时间:2023-12-01 12:11:27 24 4
gpt4 key购买 nike

我有以下代码结构:

public interface InterfaceName {
@AnnotationTwo
public void method_name();
}

public class InterfaceNameImpl implements InterfaceName{
@AnnotationOne
public void method_name() {

}
}

当我调用method_name时,会处理@AnnotationOne,但不会处理@AnnotationTwo(根据日志判断)我是否需要进行某种配置或处理 @AnnotationTwo ? (此外,注释的代码是外部的,所以我无法更改它)。理想情况下,我希望在 @AnnotationOne 之前处理 @AnnotationTwo

我在 @AnnotaionTwo 的执行周围有一个aspectj连接点,并且相应的代码没有被执行。然而,执行与关节点@AnnotationOne对应的aspectj代码。我希望在与 @AnnotationOne 对应的代码之前处理与 @AnnotationTwo 对应的代码。

注意:我正在使用 apsectj 和加载时间编织,如 here 中所述。

最佳答案

这不是最新的答案,但我相信它仍然成立:

接口(interface)方法上的注解在实现接口(interface)时不会被继承。
Annotation is not inherited from interface method
Why java classes do not inherit annotations from implemented interfaces?

关于接口(interface)方法定义上的Java注释没有被处理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27247110/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com