springcloud中@EnableDiscoveryClient与@EnableEurekaClient的区别

@EnableDiscoveryClient和@EnableEurekaClient注解都是向服务注册中心进行注册。

@EnableDiscoveryClient基于spring-cloud-commons,@EnableEurekaClient基于spring-cloud-netflix。

另外,@EnableEurekaClient具有@EnableDiscoveryClient的功能,而且更加针对于注册中心为Eureka的服务。以下是@EnableEurekaClient注解的源码

/**
 * Convenience annotation for clients to enable Eureka discovery configuration
 * (specifically). Use this (optionally) in case you want discovery and know for sure that
 * it is Eureka you want. All it does is turn on discovery and let the autoconfiguration
 * find the eureka classes if they are available (i.e. you need Eureka on the classpath as
 * well).
 *
 * @author Dave Syer
 * @author Spencer Gibb
 */
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@EnableDiscoveryClient
public @interface EnableEurekaClient {

}

  

posted on 2018-06-15 10:45  永不宕机  阅读(227)  评论(0编辑  收藏  举报

导航