1
我使用Spring RestTemplate從我的應用程序向不同的REST端點發出簡單的POST請求。目前,我設置了readTimout在Spring配置文件,如:爲RestTemplate設置讀取超時
<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中,但這是一種可接受的方式來完成此操作嗎?有沒有更好的辦法?