<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.LaxRedirectStrategy;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@Bean
public static RestTemplate restTemplate() {
return new RestTemplateBuilder()
.requestFactory(() -> new HttpComponentsClientHttpRequestFactory( HttpClientBuilder.create().useSystemProperties().setRedirectStrategy(new LaxRedirectStrategy()).build()))
.build();
复制代码
相关推荐
- 6421
-
- 2287
-
- 1328
-
引导篇(RESTful API 是什么?) REST 全称是 Representational State Transfer,中文意思是表现层(编者注:通常译为表征)状态转化, 它首次出现在 2000
- 2076
-
这里解决之前留下来的问题,当程序没有正常返回时候 就是程序由于运行时异常导致的结果,有些异常我们可,能无法提前预知,不能正常走到我们return的R对象返回。这个时候该如何处理 在SpringBoot
- 918
-