1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

pass code check

This commit is contained in:
fangjian0423
2020-01-14 16:54:01 +08:00
parent ddceb5f312
commit 00d449ba23
10 changed files with 59 additions and 54 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 the original author or authors.
* Copyright 2013-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,8 +62,13 @@ public class ConsumerSCLBApplication {
return new RestTemplate();
}
public static void main(String[] args) {
SpringApplication.run(ConsumerSCLBApplication.class, args);
}
@Configuration
@LoadBalancerClient(value = "service-provider", configuration = MyLoadBalancerConfiguration.class)
@LoadBalancerClient(value = "service-provider",
configuration = MyLoadBalancerConfiguration.class)
class MySCLBConfiguration {
}
@@ -79,7 +84,7 @@ public class ConsumerSCLBApplication {
private final Random random;
public RandomLoadBalancer(
RandomLoadBalancer(
ObjectProvider<ServiceInstanceListSupplier> serviceInstanceListSupplierProvider,
String serviceId) {
this.serviceInstanceListSupplierProvider = serviceInstanceListSupplierProvider;
@@ -104,6 +109,7 @@ public class ConsumerSCLBApplication {
return new DefaultResponse(instance);
}
}
@FeignClient(name = "service-provider")
@@ -126,6 +132,7 @@ public class ConsumerSCLBApplication {
@RestController
class TestController {
@Autowired
private RestTemplate restTemplate;
@@ -145,8 +152,4 @@ public class ConsumerSCLBApplication {
}
public static void main(String[] args) {
SpringApplication.run(ConsumerSCLBApplication.class, args);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 the original author or authors.
* Copyright 2013-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -3,4 +3,4 @@ server.port=18083
management.endpoints.web.exposure.include=*
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.loadbalancer.ribbon.enabled=false
spring.cloud.loadbalancer.ribbon.enabled=false

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 the original author or authors.
* Copyright 2013-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,8 +42,13 @@ public class ConsumerReactiveApplication {
return WebClient.builder();
}
public static void main(String[] args) {
SpringApplication.run(ConsumerReactiveApplication.class, args);
}
@RestController
class MyController {
@Autowired
private ReactiveDiscoveryClient reactiveDiscoveryClient;
@@ -63,10 +68,7 @@ public class ConsumerReactiveApplication {
.uri("http://service-provider/echo/" + name).retrieve()
.bodyToMono(String.class);
}
}
public static void main(String[] args) {
SpringApplication.run(ConsumerReactiveApplication.class, args);
}
}

View File

@@ -3,4 +3,4 @@ server.port=18083
management.endpoints.web.exposure.include=*
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.loadbalancer.ribbon.enabled=false
spring.cloud.loadbalancer.ribbon.enabled=false

View File

@@ -38,7 +38,8 @@ import org.springframework.web.client.RestTemplate;
public class ServiceApplication {
@Bean
@SentinelRestTemplate(blockHandler = "handleException", blockHandlerClass = ExceptionUtil.class)
@SentinelRestTemplate(blockHandler = "handleException",
blockHandlerClass = ExceptionUtil.class)
public RestTemplate restTemplate() {
return new RestTemplate();
}