eureka是一个注册中心,与zookeeper不同的是,eureka是restful格式的调用,zk是rpc,还有就是zk保证一致和容错,eureka则是可用和容错.

使用时首先要加入依赖

    <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>

yml文件里

server:
port: 7001
eureka:
instance:
hostname: localhost #eureka服务端的实例名称 
client:
register-with-eureka: false #falsege表示不向注册 中心注册自己
fetch-registry: false #不需要去检索服务 
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ #设置与eureka server交互的地址查询服务和注册 服务的地址

主启动类里面

@SpringBootApplication
@EnableEurekaServer //标注为eureka服务端
public class EurekaServerApp {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApp.class,args);
}
}

接着可以启动,启动好后在浏览器里输入http://locahost:7001就看到eureka的页面了。

注意:

  有时候会报错,可能是引入包冲突了,官网给了如下建议:

Finchley builds and works with Spring Boot 2.0.x, and is not expected to work with Spring Boot 1.5.x.

Note: The Dalston release train will reach end-of-life in December 2018. Edgware will follow the end-of-life cycle of Spring Boot 1.5.x.

The Dalston and Edgware release trains build on Spring Boot 1.5.x, and are not expected to work with Spring Boot 2.0.x.

NOTE: The Camden release train was marked end-of-life.

The Camden release train builds on Spring Boot 1.4.x, but is also tested with 1.5.x.

NOTE: The Brixton and Angel release trains were marked end-of-life (EOL) in July 2017.

The Brixton release train builds on Spring Boot 1.3.x, but is also tested with 1.4.x.

The Angel release train builds on Spring Boot 1.2.x, and is incompatible in some areas with Spring Boot 1.3.x. Brixton builds on Spring Boot 1.3.x and is similarly incompatible with 1.2.x. Some libraries and most apps built on Angel will run fine on Brixton, but changes will be required anywhere that the OAuth2 features from spring-cloud-security 1.0.x are used (they were mostly moved to Spring Boot in 1.3.0).

eureka学习(一)的更多相关文章

  1. Eureka学习例子

    Eureka学习 Spring Cloud下有很多工程: Spring Cloud Config:依靠git仓库实现的中心化配置管理.配置资源可以映射到Spring的不同开发环境中,但是也可以使用在非 ...

  2. springcloud Eureka学习笔记

    最近在学习springcloud,抽空记录下学习笔记;主要记录Eureka的实现过程和高可用性的实现 Eureka是一个服务治理框架,它提供了Eureka Server和Eureka Client两个 ...

  3. Spring-cloud微服务 Eureka学习教程-分布式搭建EurekaServer、EurekaClient+Ribbon(中级)

    我们这里只有一台服务器,所以我们先仿集群搭建. 完整demo项目代码:https://github.com/wades2/EurekaDemo2 在这之前我们先分析分析Eureka相比其他注册中心的好 ...

  4. Spring-cloud微服务 Eureka学习教程-分布式搭建EurekaServer、EurekaClient(中级)

    我们这里只有一台服务器,所以我们先仿集群搭建. 完整demo项目代码:https://github.com/wades2/EurekaDemo2 在这之前我们先分析分析Eureka相比其他注册中心的好 ...

  5. eureka 学习

    Eureka is a REST (Representational State Transfer) based service that is primarily used in the AWS c ...

  6. Spring Cloud Eureka 学习记录

    SpringCloud版本 <groupId>org.springframework.cloud</groupId> <artifactId>spring-clou ...

  7. Spring-cloud微服务 Eureka学习教程-单服务器配置之快速搭建EurekaServer、EurekaClient(基础)

    以下实例代码下载地址:https://github.com/wades2/EurekaDemo Eureka是Spring Cloud Netflix的一个子模块,也是核心模块之一.用于云端服务发现, ...

  8. eureka学习(二)

    eureka服务端创建好后,现在我们让eureka客户端(也就是服务提供者)注册到eureka上去. 首先加入依赖包: <!--将微服务provider注册到eureka--> <d ...

  9. eureka学习之二:自我保护机制

    提供者和消费者:消费者通过注册服务名称,找rpc远程地址,调用提供者的接口 Eureka的自我保护机制:

随机推荐

  1. JS中正则表达式

    正则表达式用于对字符串模式匹配及检索替换,是对字符串执行模式匹配的强大工具.简单来说正则表达式就是处理字符串的,我们可以用它来处理一些复杂的字符串. 1.创建方式 pattern(模式):描述了表达式 ...

  2. 【Java】定义Logger为什么要用static和final?

    private static final Logger logger= LoggerFactory.getLogger(ShiroConfig.class); (1)出于资源利用的考虑,Logger的 ...

  3. 【HDOJ6600】Just Skip The Problem(签到)

    题意:询问n!模1e6+7的结果 n<=1e9 思路: #include<bits/stdc++.h> using namespace std; typedef long long ...

  4. C#正则表达式将html代码中的所有img标签提取

    /// <summary> /// 取得HTML中所有图片的 URL. /// </summary> /// <param name="sHtmlText&qu ...

  5. 【靶场练习_sqli-labs】SQLi-LABS Page-4 (Challenges)

    Less-54: ?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where tabl ...

  6. [HDU3117]Fibonacci Numbers

    题目:Fibonacci Numbers 链接:http://acm.hdu.edu.cn/showproblem.php?pid=3117 分析: 1)后四位可以用矩阵快速幂解决.$T= \left ...

  7. vue-cli2.X环境搭建

    1.先安装nodejs环境https://npm.taobao.org/mirrors/node (选择版本) 下一步 下一步 默认安装就行 2.检查node和npm的是否成功安装node -v np ...

  8. Axure RP 8.0软件安装教程

    Axure8.0(32/64)位下载地址: 链接:https://pan.baidu.com/s/1qYSLkKW 密码:skaw 软件介绍: Axure RP是一个专业的快速原型设计工具,让负责定义 ...

  9. python让人头大的装饰器...decorator带参不带参用法和原理.,..

    0. 概念什么叫装饰器,其实也可以叫做包装器.即对于一个既有的函数func(args),在调用它之前和之后,我们希望都做一些事情,把这个函数包装起来. python中的装饰器分为两类:函数装饰器和类装 ...

  10. java知识点拾遗:)

    一篇有用的java基础知识总结http://www.cnblogs.com/xuwujing/p/8638329.html 枚举:http://blog.csdn.net/qq_27093465/ar ...