org.springframework.cloud.client.loadbalancer.LoadBalanced Java Examples
The following examples show how to use
org.springframework.cloud.client.loadbalancer.LoadBalanced.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestTemplateConfig.java From momo-cloud-permission with Apache License 2.0 | 5 votes |
@Bean
@LoadBalanced
RestTemplate restTemplate() {
HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
httpRequestFactory.setReadTimeout(3000);
httpRequestFactory.setConnectTimeout(3000);
return new RestTemplate(httpRequestFactory);
}
Example #2
Source File: LicensingserviceApplication.java From demo-project with MIT License | 5 votes |
/**
* 使用带有Ribbon 功能的Spring RestTemplate
*/
@LoadBalanced
@Bean
@SuppressWarnings("unchecked")
public RestTemplate getRestTemplate(){
RestTemplate restTemplate = new RestTemplate();
//加上拦截器,发出请求前加入管理id Header
List interceptors = restTemplate.getInterceptors();
if(interceptors==null){
restTemplate.setInterceptors(Collections.singletonList(new UserContextInterceptor()));
}else{
interceptors.add(new UserContextInterceptor());
}
return restTemplate;
}
Example #3
Source File: RestTemplateConfig.java From log-trace-spring-boot with Apache License 2.0 | 5 votes |
@Lazy
@Bean
@Primary
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
Example #4
Source File: EchoCloudConfig.java From Milkomeda with MIT License | 5 votes |
@LoadBalanced
@Bean("echoCloudRestTemplate")
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
public RestTemplate simpleRestTemplate(RestTemplateBuilder builder, ClientHttpRequestFactory factory) {
RestTemplate restTemplate = builder.build();
restTemplate.setRequestFactory(factory);
restTemplate.setErrorHandler(new EchoResponseErrorHandler());
return restTemplate;
}
Example #5
Source File: BaseResourceServerConfigurerAdapter.java From smaker with GNU Lesser General Public License v3.0 | 5 votes |
@Bean
@Primary
@LoadBalanced
public RestTemplate lbRestTemplate() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(new DefaultResponseErrorHandler() {
@Override
public void handleError(ClientHttpResponse response) throws IOException {
if (response.getRawStatusCode() != HttpStatus.BAD_REQUEST.value()) {
super.handleError(response);
}
}
});
return restTemplate;
}
Example #6
Source File: RestTemplateConfig.java From log-trace-spring-boot with Apache License 2.0 | 5 votes |
@Lazy
@Bean
@Primary
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
Example #7
Source File: RouterWebMvcConfigurer.java From spring-cloud-huawei with Apache License 2.0 | 5 votes |
@Bean
public RouterRestTemplateIntercptor routerClientHttpRequestIntercptor(
@Autowired(required = false) @LoadBalanced List<RestTemplate> restTemplates) {
RouterRestTemplateIntercptor intercptor = new RouterRestTemplateIntercptor();
if (restTemplates != null) {
restTemplates.forEach(restTemplate -> restTemplate.getInterceptors().add(intercptor));
}
return intercptor;
}
Example #8
Source File: RestTemplateConfig.java From ZTuoExchange_framework with MIT License | 4 votes |
@Bean
@LoadBalanced
RestTemplate restTemplate() {
return new RestTemplate();
}
Example #9
Source File: DemoApplication.java From SpringAll with MIT License | 4 votes |
@Bean
@LoadBalanced
RestTemplate restTemplate() {
return new RestTemplate();
}
Example #10
Source File: RestTemplateConfig.java From ZTuoExchange_framework with MIT License | 4 votes |
@Bean
@LoadBalanced
RestTemplate restTemplate() {
return new RestTemplate();
}
Example #11
Source File: WeatherAppApplication.java From Spring with Apache License 2.0 | 4 votes |
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
Example #12
Source File: ProductCompositeServiceApplication.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 4 votes |
@Bean
@LoadBalanced
public WebClient.Builder loadBalancedWebClientBuilder() {
final WebClient.Builder builder = WebClient.builder();
return builder;
}
Example #13
Source File: ServiceRibbonApplication.java From SpringCloud-Finchley-samples with Apache License 2.0 | 4 votes |
@Bean
@LoadBalanced
RestTemplate restTemplate() {
return new RestTemplate();
}
Example #14
Source File: GatewayApplication.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 4 votes |
@Bean
@LoadBalanced
public WebClient.Builder loadBalancedWebClientBuilder() {
final WebClient.Builder builder = WebClient.builder();
return builder;
}
Example #15
Source File: IngredientServiceClient.java From spring-in-action-5-samples with Apache License 2.0 | 4 votes |
public IngredientServiceClient(@LoadBalanced RestTemplate rest) {
this.rest = rest;
}
Example #16
Source File: WebClientConfig.java From spring-in-action-5-samples with Apache License 2.0 | 4 votes |
@Bean
@LoadBalanced
public WebClient.Builder webClientBuilder() {
return WebClient.builder();
}
Example #17
Source File: RestTemplateConfiguration.java From dubbo-samples with Apache License 2.0 | 4 votes |
@Bean
@LoadBalanced
RestTemplate loadBalancedRestTemplate() {
return new RestTemplate();
}
Example #18
Source File: RibbonSimpleServiceClientApplication.java From Spring with Apache License 2.0 | 4 votes |
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
Example #19
Source File: GatewayApplication.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 4 votes |
@Bean
@LoadBalanced
public WebClient.Builder loadBalancedWebClientBuilder() {
final WebClient.Builder builder = WebClient.builder();
return builder;
}
Example #20
Source File: RestTemplateConfig.java From ZTuoExchange_framework with MIT License | 4 votes |
@Bean
@LoadBalanced
RestTemplate restTemplate() {
return new RestTemplate();
}
Example #21
Source File: TimeClientApplication.java From eureka_lab with MIT License | 4 votes |
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
Example #22
Source File: DemoApplication.java From SpringAll with MIT License | 4 votes |
@Bean
@LoadBalanced
RestTemplate restTemplate() {
return new RestTemplate();
}
Example #23
Source File: ProductCompositeServiceApplication.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 4 votes |
@Bean
@LoadBalanced
public WebClient.Builder loadBalancedWebClientBuilder() {
final WebClient.Builder builder = WebClient.builder();
return builder;
}
Example #24
Source File: ServiceConsumerApplication.java From spring-boot-examples with Apache License 2.0 | 4 votes |
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
Example #25
Source File: ServiceConsumerApplication.java From spring-boot-examples with Apache License 2.0 | 4 votes |
/**
* 注入RestTemplate Bean并开启负载均衡
* @return
*/
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
Example #26
Source File: Application.java From Learning-Path-Spring-5-End-to-End-Programming with MIT License | 4 votes |
@LoadBalanced
@Bean
RestTemplate restTemplate() {
return new RestTemplate();
}
Example #27
Source File: ConsumerApplication.java From alibabacloud-microservice-demo with Apache License 2.0 | 4 votes |
@LoadBalanced
@Bean
public RestTemplate restTemplate(){
return new RestTemplate();
}
Example #28
Source File: ConsumerApplication.java From alibabacloud-microservice-demo with Apache License 2.0 | 4 votes |
@LoadBalanced
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
Example #29
Source File: Application.java From Learning-Path-Spring-5-End-to-End-Programming with MIT License | 4 votes |
@LoadBalanced
@Bean
RestTemplate restTemplate() {
return new RestTemplate();
}
Example #30
Source File: InformationClientConfiguration.java From spring-cloud-gray with Apache License 2.0 | 4 votes |
@Bean("grayInformationRestTemplate")
@LoadBalanced
@ConditionalOnMissingBean(name = {"grayInformationRestTemplate"})
public RestTemplate grayInformationRestTemplate() {
return new RestTemplate();
}