我正在尝试将名称绑定(bind)到 JAX-RS 中的过滤器,这样我就可以在其余服务中保护一些方法,如下所示:
安全名称绑定(bind):
@NameBinding
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(value = RetentionPolicy.RUNTIME)
public @interface Secured {
}
身份验证过滤器:
@Secured
@Provider
@Priority(Priorities.AUTHENTICATION)
public class AuthenticationAgent implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
//do something
}
}
但是,当我将安全注释添加到我的过滤器时,eclipse 给我这个错误。
There is no JAX-RS application, resource or resource method with this name binding annotation.
最佳答案
这些类型的错误并不是真正的大错误。对于 JAX-RS 上的此类错误,我们可以将其标记为警告或完全忽略它。
对于 Eclipse,转到 Window > Preferences > Jboss Tools > JAX-RS > JAX-RS Validator > JAX-RS Name Bindings
并将 Missing @Retention annotation
设置为除了“错误”以外的东西。 (是的,首选项名称具有误导性)。
(要为特定项目自定义它,请单击右上角的Configure Project Specific Settings...
)
关于java - Eclipse 中的 RESTeasy 名称绑定(bind)注释错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40630848/