spring cloud 使用consul作为注册中心

1.安装consul

使用docker安装

查找consul镜像    docker search consul 

下载镜像          docker pull consul

启动镜像          docker run -d -p 8500:8500  consul agent -server -bootstrap-expect=1   -

                  client 0.0.0.0 -ui

查看启动结果 netstat -tunlp       有8500启动成功    打开防火墙

使用浏览器打开8500  查看web界面

2.新建spring boot 项目

pom.xml 添加依赖

  <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>

application.properties 添加配置

server.port=8081
spring.application.name=consul-client spring.cloud.consul.host=127.0.0.1
spring.cloud.consul.port=8500 spring.cloud.consul.discovery.service-name=consul-client spring.cloud.consul.discovery.prefer-ip-address=true

启动类注解 @EnableDiscoveryClient

@SpringBootApplication
@EnableDiscoveryClient
public class ConsulClientApplication { public static void main(String[] args) {
SpringApplication.run(ConsulClientApplication.class, args);
} }

启动工程  查看consul中心服务

我这里健康检查是因为两个服务网络不互通   consul在阿里云服务器   consul-client 是本地工程

spring cloud(一) 副 consul的更多相关文章

  1. Spring Cloud 系列之 Consul 注册中心(二)

    本篇文章为系列文章,未读第一集的同学请猛戳这里:Spring Cloud 系列之 Consul 注册中心(一) 本篇文章讲解 Consul 集群环境的搭建. Consul 集群 上图是一个简单的 Co ...

  2. 服务注册发现consul之二:在Spring Cloud中使用Consul实现服务的注册和发现

    首先安装consul环境,参照之前的文章:<服务注册发现consul之一:consul介绍及安装>中的第一节介绍. Spring Cloud使用Consul的服务与发现 1.导入依赖pri ...

  3. Spring Cloud 系列之 Consul 注册中心(一)

    Netflix Eureka 2.X https://github.com/Netflix/eureka/wiki 官方宣告停止开发,但其实对国内的用户影响甚小,一方面国内大都使用的是 Eureka ...

  4. Spring Cloud 系列之 Consul 配置中心

    前面我们已经学习过 Spring Cloud Config 了: Spring Cloud 系列之 Config 配置中心(一) Spring Cloud 系列之 Config 配置中心(二) Spr ...

  5. spring cloud:搭建基于consul的服务提供者集群(spring cloud hoxton sr8 / spring boot 2.3.4)

    一,搭建基于consul的服务提供者集群 1,consul集群,共3个实例: 2, 服务提供者集群:共2个实例: 3,服务消费者:一个实例即可 4,consul集群的搭建,请参考: https://w ...

  6. Spring Cloud Consul

    1.2.0.RELEASE 该项目通过自动配置并绑定到Spring环境和其他Spring编程模型成语,为Spring Boot应用程序提供Consul集成.通过几个简单的注释,您可以快速启用和配置应用 ...

  7. 一起来学spring Cloud | 第一章:spring Cloud 与Spring Boot

    目前大家都在说微服务,其实微服务不是一个名字,是一个架构的概念,大家现在使用的基于RPC框架(dubbo.thrift等)架构其实也能算作一种微服务架构. 目前越来越多的公司开始使用微服务架构,所以在 ...

  8. Spring Cloud config之二:功能介绍

    SVN配置仓库 示例见:http://lvdccyb.iteye.com/blog/2282407 本地仓库 本地文件系统 使用本地加载配置文件.需要配置:spring.cloud.config.se ...

  9. Spring Cloud与微服务构建:Spring Cloud简介

    Spring Cloud简介 微服务因该具备的功能 微服务可以拆分为"微"和"服务"二字."微"即小的意思,那到底多小才算"微&q ...

随机推荐

  1. 目录-Linux

    Linux文件系统: Linux: glibc 程序编译方式: 动态链接 静态编译 进程的类型: 终端:硬件设备,关联一个用户接口 与终端相关:通过终端启动 与终端无关:操作引导启动过程当中自动启动 ...

  2. Golang Gin实践 番外 请入门 Makefile

    Golang Gin实践 番外 请入门 Makefile 原文地址:Golang Gin实践 番外 请入门 Makefile 前言 含一定复杂度的软件工程,基本上都是先编译 A,再依赖 B,再编译 C ...

  3. 【hihocoder 1473】小Ho的强迫症

    [题目链接]:http://hihocoder.com/problemset/problem/1473 [题意] [题解] 假定初始为在在0位置(相对它左边那条线); 则考虑; 多少步之后,人又能这到 ...

  4. oracle给表及列添加注释

    给表添加注释 comment on   table    MW_SYS.MWT_OM_OBJ1 is '业务类型的对象实例.'; 给表中的列添加注释 comment on column MW_SYS. ...

  5. A. Feed the cat

    A. Feed the cat time limit per test: 1 second memory limit per test: 256 megabytes input: standard i ...

  6. HDU 1240

    #include <iostream> #include <cstdio> using namespace std; ; char maze[MAX][MAX][MAX]; s ...

  7. [Javascript Crocks] Safely Access Object Properties with `prop`

    In this lesson, we’ll use a Maybe to safely operate on properties of an object that could be undefin ...

  8. CentOS 7 安装Nginx做反向代理

    题记 须要使用nginx的反向代理功能,測试环境为centos+NGINX 1.8.0. 跳过一些繁琐的问题,直接记录核心 步骤 (1)centos 安装在VM中.因此须要注意网络连接问题 (2)安装 ...

  9. js导出table中的EXCEL总结

    导出EXCEL通常是用PHP做,可是项目中,有时候PHP后端project师返回的数据不是我们想要的,作为前端开发project师,把相应的数据编号转换为文字后,展示给用户.可是.需求要把数据同一时候 ...

  10. Linux命令(八)——vi编辑器的使用

    vi编辑器是linux系统下的标准正文编辑器,有三种基本模式:命令行模式.插入模式和底行命令模式. 1.命令行模式:控制屏幕光标的移动,字符.字或行的删除,移动复制某区段及进入插入模式或底行命令模式下 ...