添加负载均衡的RestTemplate

This commit is contained in:
wangkang
2017-08-03 15:18:45 +08:00
parent 5e25dd9643
commit 2c1ed50008
@@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.module.SimpleModule;
import org.itkk.udf.core.xss.XssStringJsonSerializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@@ -61,6 +62,18 @@ public class BaseApplication {
return objectMapper;
}
/**
* 描述 : restTemplate
*
* @param requestFactory requestFactory
* @return RestTemplate
*/
@Bean
@LoadBalanced
public RestTemplate restTemplate(ClientHttpRequestFactory requestFactory) {
return new RestTemplate(requestFactory);
}
/**
* 描述 : externalRestTemplate
*