1.搭建

创建一个Springboot项目,添加依赖

<dependencies>
<!--添加Eureka服务器端依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
</dependencies> <dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

application.yml中添加配置

spring:
application:
name: eureka-server
server:
port: 8003
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.name}:${server.port}

启动项目,浏览器中打开如下:

2.注册服务

创建另一个服务,添加依赖

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies> <dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

bootstrap.yml中添加配置

spring:
application:
name: oauth2
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8003/eureka

服务发现与注册-Eureka的更多相关文章

  1. 服务发现和注册和Eureka

    一 Spring Cloud特点 # 约定优于配置 # 开箱即用,快速启动 # 适用于各种环境,可以部署在PC server或者 云环境 # 轻量级的组件 # 组件的支持很丰富,功能齐全 # 选型中立 ...

  2. SpringCloud微服务实战一:Spring Cloud Eureka 服务发现与注册中心(高可用实列为两个注册中心)

    微服务架构: 微服务架构的核心思想是,一个应用是由多个小的.相互独立的.微服务组成,这些服务运行在自己的进程中,开发和发布都没有依赖.不同服务通过一些轻量级交互机制来通信,例如 RPC.HTTP 等, ...

  3. 我是服务的执政官-服务发现和注册工具consul简介

    服务发现和注册 我们有了两个服务.服务A的IP地址是192.168.0.1,端口9001,服务B的IP地址192.168.0.2,端口9002.我们的客户端需要调用服务A和服务B,我们只需要在配置文件 ...

  4. 微服务的发现与注册--Eureka

    目录 服务提供者.服务消费者.服务发现组件三者之间的关系 Eureka 简介 Eureka Server Eureka Client 编写Eureka Server 将微服务注册到Eureka Ser ...

  5. 服务发现组件之 — Eureka

    前言 现在流行的微服务体系结构正在改变我们构建应用程序的方式,从单一的单体服务转变为越来越小的可单独部署的服务(称为微服务),共同构成了我们的应用程序.当进行一个业务时不可避免就会存在多个服务之间调用 ...

  6. 使用docker+consul+nginx集成分布式的服务发现与注册架构

    一.环境说明: 1.一台虚拟机,该系统已经装好了docker: ip 192.168.10.224 虚拟网卡,与主机互通 操作系统rhel6 内核 2.6.32  64位 docker版本 1.7.1 ...

  7. dubbo的服务发现和注册如何实现

    Dubbo通常我们是如何使用的? #================================================================================== ...

  8. Spring服务发现和注册

  9. SpringCloud服务注册与服务发现之Eureka

    Eureka是SpringCloud Netflix的子模块之一,用于云端的服务发现,服务定位,实现云端中间层服务发现和故障转移.服务注册与发现对于微服务系统来说十分的重要,有了服务注册与发现,就省去 ...

随机推荐

  1. springcloud中常用的注解@

    @SpringBootApplication是springboot启动类,包括三个注解,他们的作用分别是: @Configuration:表示将该类作用springboot配置文件类 @EnableA ...

  2. 切换本地凭据(Windows上登录的GitHub账号)

    切换本地用户,可以向微软小娜搜索Windows凭据,这个步骤可以参考这篇博客 的说明.

  3. 解决Spring JdbcTemplate调用queryForObject()方法结果集为空时报异常

    JdbcTemplate用的时候发现一个问题:调用queryForObject()方法,如果没有查到东西则会抛一个异常:org.springframework.dao.EmptyResultDataA ...

  4. Aura Component Skills & Tools

    本篇参考: https://trailhead.salesforce.com/content/learn/modules/lex_dev_lc_vf_fundamentals 不知不觉已经做了三年多的 ...

  5. spring技术小结

    1.DI和IOC 依赖注入(Dependency Injection)还是控制反转(Inversion of Conctrol) bean通过依赖注入,注册到spring容器里面.spring容器通过 ...

  6. Invoke PowerShell by UiPath

    UiPath能够调用PowerShell ,最近在项目中得到了实践:  需求: 某系统生成的日志文件的名字,时间戳只到分,形如bz20180214_1655.log    这样在如果在1分钟内生成多个 ...

  7. C# 的两种debug 方法

    第一种:需要把调试方法改成debug代码用 #if DEBUG 包裹 using System; using System.Collections.Generic; using System.Text ...

  8. 转---JS 获取鼠标左右键

    原文:http://blog.csdn.net/mine3333/article/details/7291557 function test() { alert(event.x+" &quo ...

  9. Python开发环境Wing IDE搜索工具介绍

    Wing IDE编辑器的搜索工具提供了一个基于友好GUI的搜索和替换工具. 某些情况下搜索可能会跨越整个文件,也有可能被限制到当前所选择的区域:可以区分大小写,也可以设置为不区分:可以被限制为只匹配整 ...

  10. linux书籍推荐

    <Linux/Unix设计思想> 图书将Unix与Linux的原理有效地结合起来,总结了Unix/Linux软件开发中的原则.在保留了第1版中Unix方面的内容的同时,强调了Linux和开 ...