我正在使用Jersey-client-2.28库发出REST请求。 我在网络上找到了有助于日志记录的代码,并且工作正常。
我遇到的问题是我不想实际发送请求。换句话说,我不想将数据放在网上。我想要的只是准备请求对象,然后打印它。
泽西岛有可能吗?
Feature feature = new LoggingFeature(logger, Level.INFO, null, null);
Client client = ClientBuilder.newBuilder().register(feature).build();
URI baseUri = UriBuilder.fromUri(baseUrl).build();
WebTarget target = client.target(baseUri);
Builder b = target.path("somepath").request();
// I want to log the request here, before sending the request
Response response = b.put(Entity.json(jsonString));
//At this point request is sent and response is received.