consul服务注册与发现

consul

Consul  https://www.consul.io/intro/index.html 是一套开源的分布式服务发现和配置管理系统,由hashiCorp公司用Go语言开发

提供了微服务系统中的服务治理、配置中心、控制总线等功能。这些功能中的每一个都可以根据需要单独使用,也可以一起使用以构建一个全方位的服务网格,总之Consul提供了一种完整的服务网格解决方案。

它具备很多的优点:支持健康检查、Http和DNS协议、支持跨数据中心的WAN集群、提供图形界面、跨平台:Windows、Mac、Linux。

 

Consul中文文档: https://www.springcloud.cc/spring-cloud-consul.html

springBoot项目整合consul

pom:

 <!-- springCloud Consul-server -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-consul-discovery</artifactId>
        </dependency>

yml:

####  consul服务端口号
server:
  port: 8006


spring:
  application:
    name: consul-provider-payment
  cloud:
  # consul 注册中心地址
    consul:
      host: localhost
      port: 8500
      discovery:
        service-name: ${spring.application.name}

原文地址:https://www.cnblogs.com/dw3306/p/12636267.html