【问题标题】:CDI compilation failure - annotation type not applicable to this kind of declarationCDI 编译失败 - 注释类型不适用于此类声明
【发布时间】:2017-11-12 19:29:35
【问题描述】:

我有一个这样声明的焊接限定符注释:

@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

我确定我遗漏了一些明显的东西,但它是什么让我无法理解。任何帮助将不胜感激。

【问题讨论】:

    标签: java cdi weld


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-01
      • 2013-10-14
      • 1970-01-01
      • 1970-01-01
      • 2021-07-28
      • 1970-01-01
      相关资源
      最近更新 更多