사용자 도구

사이트 도구


springframework:resttemplate

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
springframework:resttemplate [2018/06/22 08:51]
kwon37xi
springframework:resttemplate [2020/07/20 16:34]
kwon37xi [SpringBoot]
줄 3: 줄 3:
   * [[http://www.baeldung.com/rest-template|Spring RestTemplate Tutorial]]   * [[http://www.baeldung.com/rest-template|Spring RestTemplate Tutorial]]
   * [[http://www.baeldung.com/spring-rest-template-list|Get and Post Lists of Objects with RestTemplate | Baeldung]]   * [[http://www.baeldung.com/spring-rest-template-list|Get and Post Lists of Objects with RestTemplate | Baeldung]]
 +  * [[https://www.baeldung.com/spring-rest-template-builder|Configure a RestTemplate with RestTemplateBuilder | Baeldung]]
 +  * [[https://howtodoinjava.com/spring-boot2/resttemplate/|Spring Boot RestTemplate Tutorials - HowToDoInJava]]
  
 ===== HttpEntity ===== ===== HttpEntity =====
줄 66: 줄 68:
 restTemplate.setInterceptors(Lists.newArrayList(new RestTemplateLoggingInterceptor())); // RestTemplateLoggingInterceptor는 로그를 남기는 구현. body를 읽어버림. restTemplate.setInterceptors(Lists.newArrayList(new RestTemplateLoggingInterceptor())); // RestTemplateLoggingInterceptor는 로그를 남기는 구현. body를 읽어버림.
 </code> </code>
 +
 +===== SpringBoot =====
 +  * with [[springframework:springboot|SpringBoot]]
 +  * ''org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration''
 +  * ''RestTemplateBuilder'' 가 존재하지 않을 경우 생성해준다.
 +  * ''RestTemplate'' 자체는 생성해주지 않고 Builder 만 만들어준다.
 +  * ''RestTemplateCustomizer'', ''RestTemplateRequestCustomizer'' Bean 들을 통해 조정해준다.
 +
 +<code java>
 +@Bean
 +public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
 +    return restTemplateBuilder
 +            .requestFactory(() -> new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()))
 +            .setConnectTimeout(Duration.ofMillis(5000)) // connection-timeout
 +            .setReadTimeout(Duration.ofMillis(5000)) // read-timeout
 +            .additionalMessageConverters(new StringHttpMessageConverter(Charset.forName("UTF-8")))
 +            .build();
 +}
 +</code>
 +===== 참조 =====
 +  * [[https://www.baeldung.com/spring-resttemplate-logging|Spring RestTemplate Request/Response Logging | Baeldung]]
  
springframework/resttemplate.txt · 마지막으로 수정됨: 2022/01/14 15:43 저자 kwon37xi