配置类:
@Bean public RestTemplate restTemplate() { SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); requestFactory.setConnectTimeout(5000); requestFactory.setReadTimeout(3500); RestTemplate restTemplate = new RestTemplate(requestFactory); return restTemplate; }
调用:SpringBoot使用Bean,调用RestTemplate
private RestTemplate restTemplate;
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/java/281665.html