【发布时间】:2015-08-26 17:42:31
【问题描述】:
我正在使用 Spring RestTemplate 从我的应用程序向不同的 REST 端点发出简单的 POST 请求。目前我在 Spring 配置文件中设置 readTimout 如下所示:
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<constructor-arg>
<bean class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory">
<property name="readTimeout" value="10000" />
<property name="connectTimeout" value="10000"/>
</bean>
</constructor-arg>
</bean>
最近我的任务是要求根据每个请求动态设置 readTimout
我想我每次发出 POST 请求时都必须使用新的超时值将新的 RequestFactory 注入到 restTemplate 中,但这是一种可以接受的方法吗?有没有更好的办法?
【问题讨论】:
标签: spring rest timeout resttemplate