用来自Apache HttpClient的默认requestFactory替换默认的requestFactory(它将动态解码GZIP):
HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory( HttpClientBuilder.create().build());RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory);
将Apache Http Client添加到pom.xml
<dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <!--Version is not needed when used with Spring Boot parent pom file --> <version>4.5.1</version></dependency>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)