Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Guice:将ContainerRequestContext注入拦截器_Java_Guice_Dropwizard - Fatal编程技术网

Java Guice:将ContainerRequestContext注入拦截器

Java Guice:将ContainerRequestContext注入拦截器,java,guice,dropwizard,Java,Guice,Dropwizard,我有一个Dropwizard应用程序,我希望能够将给定请求的ContainerRequestContext注入到拦截器中,基本上是这样的: 设置拦截器的GUI配置。 Provider ctxProvider=getProvider(ContainerRequestContext.class); bindInterceptor(Matchers.any()、Matchers.any()、new SecurityInterceptor(ctxProvider)); 我的拦截器看起来像: 公共类Se

我有一个Dropwizard应用程序,我希望能够将给定请求的
ContainerRequestContext
注入到拦截器中,基本上是这样的:

设置拦截器的GUI配置。 Provider ctxProvider=getProvider(ContainerRequestContext.class); bindInterceptor(Matchers.any()、Matchers.any()、new SecurityInterceptor(ctxProvider)); 我的拦截器看起来像:

公共类SecurityInterceptor实现MethodInterceptor{
私人最终提供商ctxProvider;
公共安全拦截器(提供程序ctxProvider){
this.ctxProvider=ctxProvider;
}
@凌驾
公共对象调用(MethodInvocation MethodInvocation)抛出可丢弃的{
ContainerRequestContext ContainerRequestContext=ctxProvider.get();
//使用ctx的逻辑
返回methodInvocation.procedure();
}
}
但是,当我尝试上述操作时,我在启动时出现以下错误

1) No implementation for javax.ws.rs.container.ContainerRequestContext was bound.

如何配置Guice以便插入
ContainerRequestContext
提供程序?

看起来您需要为ContainerRequestContext提供绑定为什么不使用HK2 AOP支持?它与球衣无缝配合。您在调用请求上下文时不会遇到任何问题。请检查。看起来您需要为ContainerRequestContext提供绑定。为什么不使用HK2 AOP支持呢?它与球衣无缝配合。您在调用请求上下文时不会遇到任何问题。退房