Spring Cloud service Discovery annotations @enablediscoveryclient and @enableeurekaclient

Source: Internet
Author: User

When using the service discovery, two kinds of annotations are mentioned, one is @enablediscoveryclient, one is @enableeurekaclient, the usage is basically the same, and today it is the same. The following is an explanation of the two found above from StackOverflow:

" Discovery Service "
in Spring-cloud-commons and picks the implementation on the classpath.
inch for is on your classpath, they is effectively the same.

The original address is: What ' s the difference between enableeurekaclient and enablediscoveryclient?

There are many implementations of discovery service in spring Cloud (Eureka, Consul, zookeeper, and so on), @ Enablediscoveryclient based on Spring-cloud-commons, @EnableEurekaClient based on Spring-cloud-netflix.

In fact, in a simpler words, if you choose the registration center is Eureka, then recommend @enableeurekaclient, if it is another registry, then recommend the use of @enablediscoveryclient.

Note @enableeurekaclient on the @enablediscoveryclient annotation, it can be said that the basic is Enableeurekaclient has @enablediscoveryclient function,

Also mentioned in the above note, in fact * * @EnableEurekaClient **z annotation is a convenient use of Eureka annotations, you can say that the use of other registries,

can use @enablediscoveryclient annotations, but using the @enableeurekaclient scenario is a single use scenario when the service takes Eureka as the registry.

@EnableEurekaClient

Our specific @enableeurekaclient of the source code to look at, as follows:

 /**   * convenience annotation for clients to Enable Eureka Discovery Configuration * (specifically). Use this (optionally) in the case you want discovery and know for sure that * it's Eureka you want. All it does was turn on discovery and let the autoconfiguration * Find the Eureka classes if they be available (i.e. you n Eed Eureka on the classpath as * well). * *   @author   Dave Syer *   @author   Spencer Gibb  */   @Target (elementtype.type) @Retention (retentionpolicy.runtime) @ Documented@inherited@enablediscoveryclient  public  @interface   enableeurekaclient {} 

Spring Cloud Service discovery annotations @enablediscoveryclient and @enableeurekaclient

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.