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 22
33import org .springframework .beans .factory .annotation .Autowired ;
44import org .springframework .cloud .client .ServiceInstance ;
5- import org .springframework .cloud .client .discovery .DiscoveryClient ;
6- import org .springframework .cloud .client .loadbalancer .LoadBalanced ;
75import org .springframework .cloud .client .loadbalancer .LoadBalancerClient ;
8- import org .springframework .stereotype .Controller ;
96import org .springframework .web .bind .annotation .GetMapping ;
107import org .springframework .web .bind .annotation .RestController ;
118import org .springframework .web .client .RestTemplate ;
@@ -25,7 +22,7 @@ public class DcController {
2522
2623 @ GetMapping ("/consumer" )
2724 public String dc () {
28- ServiceInstance serviceInstance = loadBalancerClient .choose ("eureka -client" );
25+ ServiceInstance serviceInstance = loadBalancerClient .choose ("consul -client" );
2926 String url = "http://" + serviceInstance .getHost () + ":" + serviceInstance .getPort () + "/dc" ;
3027 System .out .println (url );
3128 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
22server.port =2101
33
4- eureka.client.serviceUrl.defaultZone =http://localhost:1001/eureka/
4+ spring.cloud.consul.host =localhost
5+ spring.cloud.consul.port =8500
56
67logging.file =${spring.application.name}.log
You can’t perform that action at this time.
0 commit comments