我正在尝试升级到 Jersey 2.0,但遇到了很多麻烦,因为 Jersey 的 groupIds 和artifactIds 已完全更改,并且我在 中找不到迁移计划泽西岛文档 https://jersey.java.net/nonav/documentation/2.0/index.html.
这是我的 pom.xml 过去的样子,编译得很好:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.17</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server-linking</artifactId>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.17.1</version>
</dependency>
这些应该改成什么?这个无关的 StackOverflow 问题有点帮助, https://stackoverflow.com/questions/16216759/dependency-injection-with-jersey-2-0但我很难找到诸如在哪里的东西@Ref
注释移至。
Update
- 看起来
@Ref
不再存在或至少文档中不再提及 https://jersey.java.net/nonav/documentation/2.0/uris-and-links.html。现在你使用一个UriBuilder
.
-
我在文档中找到了一个非常有用的部分,它回答了我的 Maven 问题 https://jersey.java.net/nonav/documentation/2.0/modules-and-dependencies.html.
- The
HTTPBasicAuthFilter
已更名为HttpBasicAuthFilter
。注意大小写。
-
Client client = Client.create();
已经成为Client client = ClientBuilder.newClient();
-
This:
String json = client
.resource(getBaseUrl() + url)
.accept(MediaType.APPLICATION_JSON_TYPE)
.get(String.class);
已经成为
String json = client
.target(getBaseUrl())
.path(url)
.request(MediaType.APPLICATION_JSON_TYPE)
.get(String.class);
你不知道。
Jersey 2.0 缺少 Jersey 1.0 的许多功能。与提交者告诉您的相反,有些事情现在显然不可能实现(例如 Guice、Spring 集成)。表面上看起来一切正常,但一旦你深入挖掘,你会发现很多功能仍然被破坏。
许多 1.x 插件在 2.x 中不存在,主要是因为前面提到的损坏。
有鉴于此,我建议在可预见的将来推迟 Jersey 2.x。希望提交者能在来年解决这个问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)