相关文章推荐
刚失恋的芒果  ·  基于k8s ...·  1 周前    · 
知识渊博的闹钟  ·  API ...·  昨天    · 
安静的包子  ·  JDBC写入postgresql ...·  5 月前    · 
沉着的水桶  ·  CDialogBar Class | ...·  1 年前    · 
        <!-- 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();
复制代码
  • 私信