目前,我正在与AspectJ合作。 我在依赖项中分离了AspectJ代码。 在该依赖关系中,一切都按预期工作。 但是,一旦我将其导入另一个项目中,则仅某些功能不再起作用。 使用@DeclareParents的defaultImpl时,该接口显示在已编译的代码中,而不显示默认的Implementation。 这是我的代码,以显示我的意思(每个代码段都是其自己的文件):
AspectJ代码:
public interface IAspect
{
String hello();
}
public class IAspectDefaultImpl implements IAspect
{
@Override
public String hello()
{
return "hello";
}
}
@Aspect
public class AspectJ
{
@DeclareParents(value = "@SomeAnnotation*",defaultImpl = IAspectDefaultImpl.class)
private IAspect implementedInterface;
}
另一个项目中的目标类:
@SomeAnnotation
public class MyClass
{
private final int myValue;
public MyClass(final int wert)
{
this.myValue = wert;
}
public int getMyValue()
{
return myValue;
}
}
Maven丢了我:
The type MyClass must implement the inherited abstract method IAspect.hello()
这暗示它部分起作用。 当查看反编译的.class文件时,目标Class实际上会实现IAspect。 IAspectDefaultImpl中定义的方法仍然缺少。
我的pom的设置就像在this示例中一样。
我不确定应该从哪里开始寻找错误。 任何帮助都非常感谢。