Ribbon in the case of Eureka, can not use Eureka, quite simple, directly on the code
Application.xml
Server:port:7002Spring: # Set the name registered in Eureka, all lowercase, otherwise the case mixed with the problem Application:name:microservice-consumer-movie-ribben-Ymllogging:level:root:INFO Org.hibernate:INFO Org.hibernate.type.descriptor.sql.BasicBinder:TRACE or G.hibernate.type.descriptor.sql.basicextractor:trace Com.itmuch:DEBUGeureka:client:serviceUrl:defaultZone : http://Wenbronk:[email Protected]:8761/eureka# Add the IP in the registry instead of the host name Instance:prefer-ip-c:trueinstance-ID: ${spring.application.name}:${spring.cloud.client.ipaddress}:${spring.application.instance_id:${ Server.port}} Statuspageurlpath: ${management.context-path}/info healthcheckurlpath: ${management.context-path}/health# Disable eurekaribbon:eureka:enabled in the Ribbon:false# Custom Ribbonclient, do not use Eureka, use this configuration Microservice-provider-User:ribbon:listOfServers:localhost:7901
2, use this method in Moviecontroller to test:
@RequestMapping ("/movie/{id}") PublicUser FindByID (@PathVariable Long ID) {Serviceinstance instance= This. Loadbalancerclient.choose ("Microservice-provider-user"); URI Storesuri= Uri.create (String.Format ("http://%s:%s", Instance.gethost (), Instance.getport ())); System. out. println ("111:"+ Instance.getserviceid () +": "+ instance.gethost () +": "+Instance.getport ()); return NULL;//return Resttemplate.getforobject ("http://microservice-provider-user/simple/"+ ID, user.class);}
After the client initiates the request, you can see that only 7901 ports in the log are accessed, commenting out the last 2 configurations in the YML, you will see the Eureka default polling configuration
Do not use Eureka in Springcloud-05-ribbon