zoukankan      html  css  js  c++  java
  • @EnableDiscoveryClient和@EnableEurekaClient的区别

    简单区分下,他们在功能上是一致的:写在启动类的上,开启服务注册发现功能。

    不同的是,当注册中心不一样时,像:eureka、consul、zookeeper,使用是也有了区别。

    EnableDiscoveryClient注解在common包中,通过项目的classpath来决定使用哪种实现,而EnableEurekaClient注解在netflix包中,只会使用eureka这种实现方式;

    所以,使用EnableDiscoverClient,对任何注册中心都适用。而EnableEurekaClient是为eureka服务的。

    springcloud的Dalston或更早期的版本EnableEurekaClient是包含EnableDiscoverClient注解的,这种情况使用什么已经没区别了。

    
    @Target(ElementType.TYPE)
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @Inherited
    @EnableDiscoveryClient
    public @interface EnableEurekaClient {
    
    }

    但是在之后版本,如Greenwich版本中是这样的:

    package org.springframework.cloud.netflix.eureka;
    
    import java.lang.annotation.Documented;
    import java.lang.annotation.ElementType;
    import java.lang.annotation.Inherited;
    import java.lang.annotation.Retention;
    import java.lang.annotation.RetentionPolicy;
    import java.lang.annotation.Target;
    
    @Target({ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @Inherited
    public @interface EnableEurekaClient {
    }

    官网推荐使用:EnableDiscoveryClient

    想详细了解可以看这篇博客:https://blog.csdn.net/boling_cavalry/article/details/82668480

    就算这个世道烂成一堆粪坑,那也不是你吃屎的理由
  • 相关阅读:
    用react+redux+webpack搭建项目一些疑惑
    ajax基本原理实现
    jsonp详细原理之一
    因为文件共享不安全,所以你不能连接到文件共享
    python xml模块
    python os模块
    python tickle模块与json模块
    python datetime模块
    python sys模块
    python time模块
  • 原文地址:https://www.cnblogs.com/whalesea/p/12846088.html
Copyright © 2011-2022 走看看