Do not use Eureka in Springcloud-05-ribbon

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.