我正在尝试使用 Jersey 并且它与 Spring 集成,以便在我们的 Spring Web 应用程序中拥有 jax-rs 端点。
我遇到的问题是,在我们的单元测试中没有填充使用 @Value 注释的应用程序成员。
用@Autowired 填充的那些工作正常,如果我为字符串创建一个setter 方法并用@Value 注释它也可以。
让我烦恼的是,直接使用@Value 注释的成员在测试中不起作用,但在部署到我们的 tomcat 中时起作用。
这是我们的测试配置的问题吗?或者这是某个地方的已知问题?
这些是我认为的相关依赖项:
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<scope>test</scope>
</dependency>
一个在这里举例说明问题的小项目: https ://github.com/alexanderkjall/jersey-jetty-interaction-example/blob/master/src/main/java/no/hackeriet/bugs/SpringRequestResource.java