CDI编译失败 - 注释类型不适用于此类声明

时间:2017-11-12 19:29:35

标签: java cdi weld

我有一个Weld限定符注释声明如下:

@Qualifier
@Retention(RUNTIME)
@Target({Field, Method, Constructor})
public @interface AccountResponse {
}

我的bean界面是这样的:

@Stateless
public interface Responder {
    /* Declares stuff */
}

合格的实现是:

@AccountResponse
public class AccountResponseResponder implements Responder {
    /* Does stuff */
}

Maven编译器说(在AccountResponseResponder.java上):

annotation type not applicable to this type of declaration

我确信我错过了一些明显的东西,但是它让我感到惊讶。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:3)

@Target({Field, Method, Constructor}) 意味着您只能将此注释应用于代码的给定部分。要启用类注释,您必须将Type添加到@Target