繁体   English   中英

不推荐使用ClientRequestFactory RestEasy…是否有其他RestEasy替代方案?

[英]ClientRequestFactory RestEasy Deprecated… Any other RestEasy alternative ?

我需要使用由其他人创建的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();

有人吗,现在3.0.x版的ClientRequestFactory可以轻松自在吗?

Resteasy Client-API已被标记为不推荐使用,因为JAX-RS标准化了Client-API。 您可以在文档中找到有关新Client-API的Resteasy集成的信息

您的示例可能看起来像(未经测试):

Client client = ClientBuilder.newClient();
Response response = client.target("http://url-of-service").request().get();
// read and close the response

或者,如果您想使用Resteasy代理框架:

Client client = ClientFactory.newClient();
ResteasyWebTarget target = (ResteasyWebTarget) client.target("http://url-of-service");
SomeRestInterface client = target.proxy(SomeRestInterface.class);
client.theMethod();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM