RestfulConfig.java 811 B

123456789101112131415161718192021222324
  1. package cn.jx.wechat.app.wechatrobot.config;
  2. import org.springframework.context.annotation.Bean;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
  5. import org.springframework.web.client.RestTemplate;
  6. @Configuration(proxyBeanMethods=true)
  7. public class RestfulConfig {
  8. //默认RestTemplate配置工厂(采用httpclient)
  9. @Bean("defaultAppRestFactory")
  10. public HttpComponentsClientHttpRequestFactory defaultAppRestFactory(RestProperties restProperties) {
  11. return new ComponentsHttpClientConfigBuilder()
  12. .restProperties(restProperties)
  13. .conProp(restProperties.getMaster())
  14. .build();
  15. }
  16. @Bean("c")
  17. public RestTemplate appRestTemplate() {
  18. }
  19. }