Created
October 26, 2016 17:04
-
-
Save ankushs92/37550aa0e391a7abf04b72743a965fe0 to your computer and use it in GitHub Desktop.
How to autowire RestTemplate.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean(name="testRestTemplate") | |
public RestTemplate getPubPostbackRestTemplate(){ | |
final int readTimeOut = 5000; | |
final int connectTimeout = 5000; | |
final HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = | |
new HttpComponentsClientHttpRequestFactory(); | |
clientHttpRequestFactory.setConnectTimeout(connectTimeout); | |
clientHttpRequestFactory.setReadTimeout(readTimeOut); | |
return new RestTemplate(clientHttpRequestFactory); | |
} | |
@Service | |
public class TestService{ | |
@Autowire | |
private RestTemplate testRestTemplate; | |
//Dance . | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment