java - 移动设备上符合 JAX-RS 的实现
问题描述
我正在编写一个应该在桌面和移动设备上运行的应用程序,它需要使用 REST 与服务器通信。我正在使用 Gluon Mobile。
我在客户端编写的代码是符合 jax-rs 的,如下所示:
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
Client client = ClientBuilder.newBuilder().build();
WebTarget target = client.target("http://www...").path("/login/...");
Future<Response> future = target.request().async().get();
Response response = future.get();
我指定了对 RESTEASY 或 Jersey 客户端等实现的依赖。
Gluon Connect 具有 REST 实现,但不符合 JAX-RS:
RestClient restClient = RestClient.create()
.method("GET")
.host("https://...")
.path("/login/...")
...
这意味着我的客户需要 2 个代码版本。我想像使用其余代码一样编写一次运行任何地方。可能吗?我可以在 android 和 ios 上使用 JAX-RS 实现吗?我需要告诉 gradle 在为 android 和 ios 构建桌面和其他实现时使用一种实现,对吗?
解决方案
推荐阅读
- ruby-on-rails - Rails 路线中不包含 id
- laravel - laravel 5:如何验证多维复选框
- python - ModuleNotFoundError 在龙卷风中加载腌制文件时
- javascript - 将输入数据保存到同一页面上的表中?HTML 和 Javascript
- javascript - 图像在 JS 的这个对象程序中第一次没有显示
- javascript - 更新期间不会删除 d3 图表中的旧节点
- haskell - Haskell 函数依赖一致性条件:需要吗?用了吗?
- unity3d - Unable To Download MAC Os Build Option in Unity
- javascript - React, Firebase: Access values of JSON and also get key value
- xamarin.android - Xamarin.Android binding generation giving "Type X was not found" errors for classes new in JDK 1.8