Tag: jsr311

尝试向Jersey注入自定义上下文时缺少字段依赖项

我有一个自定义上下文: public class MyContext { public String doSomething() {…} } 我创建了一个上下文解析器: @Provider public class MyContextResolver implements ContextResolver { public MyContext getContext(Class type) { return new MyContext(); } } 现在在资源中我尝试注入它: @Path(“/”) public class MyResource { @Context MyContext context; } 我收到以下错误: SEVERE: Missing dependency for field: com.something.MyContext com.something.MyResource.context 相同的代码在Apache Wink 1.1.3中运行良好,但在Jersey 1.10中失败。 任何想法将不胜感激。