我有以下代码它抛出的错误。我们如何在没有连接重置错误的情况下使用httpclient调用api。
java.util.concurrent.executionexception:java.io.ioexception:java.base/java.util.concurrent.completablefuture.reportget(completablefuture)的对等方重置连接。java:395)在java.base/java.util.concurrent.completablefuture.get(completablefuture。java:1999)
@Bean
public HttpClient httpClient() {
return java.net.http.HttpClient.newHttpClient();
}
HttpRequest req =
HttpRequest.newBuilder(URI.create(url))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + tokenValue)
.header("User-Agent", "admins-api")
.POST(HttpRequest.BodyPublishers.ofString(inputJson))
.build();
暂无答案!
目前还没有任何答案,快来回答吧!