Ada*_* G. 2 java deprecated java-ee resteasy
我需要创建rest-easy客户端,使用其他人创建的RestService的de接口......这样做很好,除了一件事......
当我从rest-easy 2.3.5.Final更新到rest-easy 3.0.x时,ClientRequestFactory类看起来像@Deprecated.
实际代码是:
ClientRequestFactory crf = new ClientRequestFactory(UriBuilder.fromUri("http://url-of-service").build());
SomeRestInterface client = crf.createProxy(SomeRestInterface.class);
client.theMethod();
Run Code Online (Sandbox Code Playgroud)
任何一个,现在什么是版本3.0.x的ClientRequestFactory的rest-easy替代方案?
由于JAX-RS标准化了Client-API,因此Resteasy Client-API已被标记为已弃用.您可以在文档中找到有关新Client-API的Resteasy集成的信息.
您的示例可能看起来像(未经测试):
Client client = ClientBuilder.newClient();
Response response = client.target("http://url-of-service").request().get();
// read and close the response
Run Code Online (Sandbox Code Playgroud)
或者,如果您想使用Resteasy Proxy Framework:
Client client = ClientFactory.newClient();
ResteasyWebTarget target = (ResteasyWebTarget) client.target("http://url-of-service");
SomeRestInterface client = target.proxy(SomeRestInterface.class);
client.theMethod();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3953 次 |
| 最近记录: |