使用 HK2 注入框架,我开发了一个自定义注释,用于在我的类中注入我的自定义对象。
如果我将我的对象注释为类变量,一切正常:
public class MyClass {
@MyCustomAnnotation
MyType obj1
@MyCustomAnnotation
MyType obj2
...
现在我需要将我的对象作为构造函数参数注入,即:
public class MyClass {
MyType obj1
MyType obj2
@MyCustomAnnotation
public MyClass(MyType obj1, MyType obj2){
this.obj1 = obj1;
this.obj2 = obj2;
}
...
在我的注入解析器中,我覆盖了:
@Override
public boolean isConstructorParameterIndicator() {
return true;
}
为了返回真。
问题是当我尝试构建我的项目时,它会捕获一个错误消息:
"The annotation MyCustomAnnotation is disallowed for this location"
我错过了什么?