resttemplate 相关问题

将此标记用于Spring的RestTemplate,这是一个用于客户端HTTP通信和RESTful原则实施的类。

org.springframework.web.client.HttpClientErrorException:404 null

我有这样的 RestTemplate: RestTemplaterestTemplate = new RestTemplate(); HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setContentType(MediaType.APPLICATION_J...

回答 2 投票 0

获取RestTemplate(连接重置)尽管一切都正确

我正在使用 Spring Boot RestTemplate 来调用 REST API。 在 PROD 上,我遇到以下异常: org.springframework.web.client.ResourceAccessException:“https:// 的 POST 请求发生 I/O 错误” 我正在使用 Spring Boot RestTemplate 来调用 REST API。 在 PROD 上,我遇到以下异常: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://<host>/v2/graphql": Connection reset; nested exception is java.net.SocketException: Connection reset at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:711) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:602) 客户端的请求到达网关,网关也转发给服务器。服务器已成功处理请求,但连接在不到 5 秒内被重置。 这些是 RestTemplate 的 http 配置: connectionRequestTimeoutMs: 3000 connectTimeoutMs: 3000 readTimeoutMs: 3000 maxConnectionsTotal: 100 maxConnectionsPerRoute: 100 总共 2300 个请求中,只有 8 个请求因连接重置错误而失败,但我想了解为什么会发生这种情况。 任何帮助将不胜感激。预先感谢! 你能解决这个问题吗?如果是的话请告诉我答案

回答 1 投票 0

无法找到到达请求目标的有效认证路径

我正在使用restTemplate发出发布请求,但收到以下错误:无法找到请求目标的有效证书路径 org.springframework.beans.factory.BeanCreationExc...

回答 3 投票 0

带有 MultipartFile 列表的 POST 请求

我正在尝试使用多部分表单数据执行 POST 请求。我有这个控制器接收请求 @PostMapping(value = "/photos", 消耗 = MediaType.MULTIPART_FORM_DATA_VALUE) ...

回答 1 投票 0

获取org.mockito.exceptions.misusing.PotentialStubbingProblem:使用restTemplate时严格存根参数不匹配

我在应用程序中使用 RestTemplate 的 Exchange() 来调用外部 API。目前,我正在为restTemplate调用编写junit和mockito测试用例,但我发现存根参数不匹配

回答 1 投票 0

如何在 Spring MVC 的 RestTemplate 中传递 %22 作为过滤器

1.requestURL = https://test.env123.com:8081/select/0/prometheus/api/v1/query_range?query=test.link.packets{billid=%22P1yhABCnWJ7WhI%22}&start=2023- 08-10T01:02:03Z&结束=2023-08-26T01:02:03Z

回答 1 投票 0

如何实现通过 RestTemplate 执行的 PATCH?

我正在编写 JUnit 测试,通过 RestTemplate 调用我的应用程序。我已经成功实现了 GET、POST 和 PUT,但无法运行 PATCH(尽管它在客户端发送 U...

回答 7 投票 0

spring kotlin RestTemplate - 如何解析响应中的 JSON 数组

我一直在努力使用 Spring 与 Kotlin 和 RestTemplate 将 JSON 数组表示的响应解析为数据类实体。非数组类响应没有问题,即。以下...

回答 1 投票 0

如何在 Spring Test 的 RestTemplate 中创建带有 json 内容类型标头的纯 http 请求?

有一个简单的rest/api spring boot项目,当架构输入错误时需要测试,如下所示: curl -D- -X POST -H '内容类型:application/json' \ -d '坏架构-$@#%{[|!/-' \ http://127.0....

回答 1 投票 0

实现HTTP连接池的正确方法

我在 REST API 调用某些 Web 服务期间使用 Apache HTTP 客户端进行连接池。 奇怪的是,尽管我使用 HTTP 连接池,但我的

回答 3 投票 0

HttpRetryException:由于服务器身份验证,在流模式下无法重试

即使我的代码中没有任何重试逻辑,我也会在 POST 请求中收到此错误。 我的应用程序在 spring boot 版本 2.6.4 和 java 17 上运行。 {url} 的 POST 请求发生 I/O 错误:

回答 1 投票 0

在 Spring RestTemplate 中禁用 SSL 证书验证

我在两台不同的机器上有两个基于 Spring 的 Web 应用程序 A 和 B。 我想从 Web 应用程序 A 到 Web 应用程序 B 进行 HTTPS 调用,但是,我在机器 B 中使用自签名证书。所以我的...

回答 10 投票 0

HttpClientErrorException$BadRequest:400:调用restTemplate.postForObject时[无正文]

我正在调用用 SpringBoot 编写的 POST 服务 getOrder3 ,该服务工作正常(在 Postman 中测试),但是当从另一个服务通过restTemplate.postForObject 调用时出现错误。我尝试了2个

回答 2 投票 0

Spring RestTemplate 不支持流式传输

关于如何使 RestTemplate 流式传输请求的问题,有很多答案。 为什么 RestTemplate 会消耗过多的内存? 使用 RestTemplate POST 输入流 看起来...

回答 1 投票 0

Java Spring RestTemplate getForObject 响应未正确解码

我正在尝试执行一个 HTTP GET 请求,我可以使用 RestTemplate 类在 Spring Boot 应用程序的 Postman 中正确执行该请求。 这是我用来发送请求的代码: 休息...

回答 1 投票 0

使用 Spring Boot RestTemplate 时在响应标头中收到不正确的内容类型

在提供的代码片段中,我使用 Spring Boot 的 RestTemplate 发出 HTTP GET 请求。目的是根据收到的响应的内容类型执行特定的业务逻辑...

回答 1 投票 0

如何模拟带有客户端或服务器错误的 RestTemplate?

我在代码中使用了restTemplate.postForEntity()。 在测试围绕它的类时,我使用 Mockito 来模拟 RestTemplate。 Mockito.when(restTemplate.postForEntity(.....)).thenReturn(response) 哪里

回答 3 投票 0

在 Java 中使用 RestTemplate 通过 API 调用提交 google 表单不起作用

每当在我的应用程序上执行新注册时,我都必须提交此 Google 表单,因此我在 Java Spring Boot 中使用 RestTemplate 来发送 API 请求并将所有表单数据作为查询参数填充....

回答 1 投票 0

spring mvc Rest服务重定向/转发/代理

我已经使用spring mvc框架构建了一个Web应用程序来发布REST服务。 例如: @控制器 @RequestMapping(“/电影”) 公共类MovieController { @RequestMapping(值...

回答 9 投票 0

Java Spring RestTemplate 超时无法正常工作

我有这样的场景,我向API发出请求,假设我正在使用restTemplate.exchange方法执行该请求。我确实这样设置超时: ((HttpComponentsClientHttpRequestFactory)

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.