LANGUAGE/Java & Groovy 2016. 1. 26. 13:06

///// Spring (스프링)




///// RestTemplate




///// RestTemplate Timeout In Java (자바에서 RestTemplate 타임아웃 설정)

HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();

factory.setReadTimeout(2000); //milliseconds

factory.setConnectionTimeout(2000); // milliseconds

RestTemplate restTemplate = new RestTemplate();




///// RestTemplate Timeout In Spring (스프링에서 RestTemplate 타임아웃설정)

<bean class="org.springframework.web.client.RestTemplate">

     <constructor-arg>

         <bean class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory" p:readtimeout="2000" p:connecttimeout="2000">

     </bean></constructor-arg>

</bean>




///// 참고

Spring RestTemplate timeout 지정: http://www.bboks.net/384