相关文章推荐
想发财的遥控器  ·  swing ...·  1 年前    · 
性感的凉面  ·  报错Intel MKL FATAL ...·  1 年前    · 
酒量大的西红柿  ·  java - Test Unit ...·  2 年前    · 
        <!-- 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();
复制代码
  • 私信