File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed
2-Dalston版教程示例/consul-consumer/src/main Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import org .springframework .beans .factory .annotation .Autowired ;
4
4
import org .springframework .cloud .client .ServiceInstance ;
5
- import org .springframework .cloud .client .discovery .DiscoveryClient ;
6
- import org .springframework .cloud .client .loadbalancer .LoadBalanced ;
7
5
import org .springframework .cloud .client .loadbalancer .LoadBalancerClient ;
8
- import org .springframework .stereotype .Controller ;
9
6
import org .springframework .web .bind .annotation .GetMapping ;
10
7
import org .springframework .web .bind .annotation .RestController ;
11
8
import org .springframework .web .client .RestTemplate ;
@@ -25,7 +22,7 @@ public class DcController {
25
22
26
23
@ GetMapping ("/consumer" )
27
24
public String dc () {
28
- ServiceInstance serviceInstance = loadBalancerClient .choose ("eureka -client" );
25
+ ServiceInstance serviceInstance = loadBalancerClient .choose ("consul -client" );
29
26
String url = "http://" + serviceInstance .getHost () + ":" + serviceInstance .getPort () + "/dc" ;
30
27
System .out .println (url );
31
28
return restTemplate .getForObject (url , String .class );
Original file line number Diff line number Diff line change 1
- spring.application.name =eureka -consumer
1
+ spring.application.name =consul -consumer
2
2
server.port =2101
3
3
4
- eureka.client.serviceUrl.defaultZone =http://localhost:1001/eureka/
4
+ spring.cloud.consul.host =localhost
5
+ spring.cloud.consul.port =8500
5
6
6
7
logging.file =${spring.application.name}.log
You can’t perform that action at this time.
0 commit comments