从Jersey迁移到RestEasy

时间:2018-05-30 10:04:54

标签: resteasy jersey-2.0

我正在努力从MSBuild /t:restore迁移到jersey服务。

迁移时,我试图在RestEasy中找到RestEasy发布方法中的等效方法。

WebResource

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

jax-rs 2.0(json)用resteasy做这个的方法是:

创建客户

创建WebTarget

final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
final CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm).build();
cm.setMaxTotal(200);
cm.setDefaultMaxPerRoute(20);

final ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient);

final Client client = new ResteasyClientBuilder().httpEngine(engine).register(ResteasyJackson2Provider.class).build();

对您的终端进行POST调用

final ResteasyWebTarget webtarget = (ResteasyWebTarget) client.target(serviceUrl);