【发布时间】:2016-03-02 07:46:09
【问题描述】:
我正在尝试使用 spring 注入在 Jersey-Filter 中注入一个对象。
如果我尝试 @Inject 方法,那么我会遇到异常
SEVERE: StandardWrapper.Throwable
MultiException stack 1 of 2
java.lang.IllegalStateException: Could not find an active context for org.jvnet.hk2.spring.bridge.api.SpringScope
at org.jvnet.hk2.internal.ServiceLocatorImpl._resolveContext(ServiceLocatorImpl.java:2058)
at org.jvnet.hk2.internal.ServiceLocatorImpl.access$000(ServiceLocatorImpl.java:120)
at org.jvnet.hk2.internal.ServiceLocatorImpl$2.compute(ServiceLocatorImpl.java:186)
at org.jvnet.hk2.internal.ServiceLocatorImpl$2.compute(ServiceLocatorImpl.java:182)
如果我尝试使用它在 Jersey 1.x 中定义的 @InjectParam,但是我使用的是 Jersey 2.17,其中找不到此注释。
知道如何在 jersey-filter 中执行此弹簧注射吗?
异常是什么意思?
Could not find an active context for org.jvnet.hk2.spring.bridge.api.SpringScope
【问题讨论】:
-
在我看来,在初始化时,弹簧桥尚未正确初始化。我不确定在泽西岛是如何做到的,但你可以在这里看到更多关于 spring/hk2 桥的信息:hk2.java.net/2.5.0-b03/spring-bridge.html
标签: spring dependency-injection jersey-2.0