ClientRequestFactory RestEasy已弃用……任何其他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();
任何一个,现在什么是版本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
或者,如果您想使用Resteasy Proxy Framework:
Client client = ClientFactory.newClient(); ResteasyWebTarget target = (ResteasyWebTarget) client.target("http://url-of-service"); SomeRestInterface client = target.proxy(SomeRestInterface.class); client.theMethod();
- 为什么将HashSet (0)初始化为零?
- 使用Jackson的JSON反序列化:没有为类型找到合适的构造函数 – 提供默认构造函数或注释构造函数是不可能的
- ApplicationContext和ServletContext
- Web项目中的Java文件路径
- java.sql.SQLException:超出锁定等待超时; 尝试在MYSQL中重启事务exception
- 在正则表达式世界中,Java使用的是什么味道和风味?
- 什么是“git merge-base –fork-point branchA branchB”的jgit等价物
- 在Java枚举中停止重复
- 用于Java的JSON String tidy / formatter