1.安装

sudo yum install -y yum-utils

sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo

sudo yum -y install consul

检查是版本号:consul --version

2.启动

consul agent -dev -ui -node=consul-dev -client=(主机ip,便于访问)

3.创建一个maven项目

4.导入相关pom文件

 <dependencies>

        <!--引入通用的api-commons.jar包-->
<dependency>
<groupId>com.qbb.springcloud</groupId>
<artifactId>cloud-api-commons</artifactId>
<version>${project.version}</version>
</dependency> <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-consul-discovery -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency> <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency> <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency> <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency> <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> </dependencies>

5.修改yml文件

server:
port: 8006 spring:
application:
name: consul-consumer-order
cloud:
consul:
host: 192.168.140.132 # 使用的linux服务ip
port: 8500 # 默认端口
discovery:
service-name: ${spring.application.name}

6.写主启动类

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

7.写controller层测试

@RestController
@Slf4j
public class PaymentController {
@Value("${server.port}")
private String serverPort; @RequestMapping("/payment/consul")
public String paymentZk() {
return "springcloud with consul:" + serverPort + "\t" + UUID.randomUUID().toString() + System.currentTimeMillis();
}
}

结果

Consul安装启动的更多相关文章

  1. Consul安装使用

    安装 安装环境: Mac 我参照官网下载,然后解压,然后添加到PATH,并不能用.最终使用brew安装成功. brew install consul 安装成功后,文件位于/usr/local/Cell ...

  2. Consul安装集群搭建

    1 consul的安装和配置 1.1 consul agent 命令介绍 下载consul_1.0.0_linux_amd64.zip解压,里面只有一个consul可执行文件,其中,consul最常用 ...

  3. postman使用之一:安装启动篇

    官网介绍:http://www.getpostman.com/docs/ postman是干什么的就不介绍了,本文从postman的安装开始介绍,后续会有其它使用的介绍. 安装: 1.mac app安 ...

  4. consul 安装

    1. linux 下consul 安装 首先查看机器信息: uname -a Linux centos-linux.shared 3.10.0-327.el7.x86_64 #1 SMP Thu No ...

  5. MySQL 安装 启动 基本语法概述

    MySQL 安装 启动 基本语法概述 MySQL安装和配置 我是直接使用安装包:mysql-installer-community-5.6.10.1.msi 安装的时候其中有几点要注意: 1.记住端口 ...

  6. MySQL 安装 启动命令总结

    MySQL 安装 启动 基本语法概述 MySQL安装和配置 我是直接使用安装包:mysql-installer-community-5.6.10.1.msi 安装的时候其中有几点要注意: 1.记住端口 ...

  7. mysql安装启动教程(两种方法)

    mysql安装启动: 方法一(简单版): cmd进入mysql安装的bin目录:mysqld.exe –install net start mysql  服务启动(或者选择计算机->(右键)管理 ...

  8. Ubuntu 安装启动Tomcat

    首先下载ubuntu 的tar包 官网: http://tomcat.apache.org/download-80.cgi 安装启动 1 .下载对应的tar 2 .解压任意文件夹下,更改名字tomca ...

  9. windows服务安装启动报错误1053:服务没有及时响应启动或控制请求

    <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0&qu ...

随机推荐

  1. Python网络编程之网络基础

    Python网络编程之网络基础 目录 Python网络编程之网络基础 1. 计算机网络发展 1.1. OSI七层模型 1.2. 七层模型传输数据过程 2. TCP/IP协议栈 2.1 TCP/IP和O ...

  2. Python与Javascript相互调用超详细讲解(2022年1月最新)(一)基本原理 Part 1 - 通过子进程和进程间通信(IPC)

    TL; DR 适用于: python和javascript的runtime(基本特指cpython[不是cython!]和Node.js)都装好了 副语言用了一些复杂的包(例如python用了nump ...

  3. leetcode 13. 罗马数字转整数 及 12. 整数转罗马数字

    13. 罗马数字转整数 问题描述 罗马数字包含以下七种字符: I, V, X, L,C,D 和 M. 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如,罗马数 ...

  4. golang gin框架中实现"Transfer-Encoding: chunked"方式的分块发送数据到浏览器端

    参考了这篇帖子: https://golangtc.com/t/570b403eb09ecc66b90002d9 golang web如何发送小包的chunked数据 以下是代码: r.GET(&qu ...

  5. [源码分析] Facebook如何训练超大模型 --- (3)

    [源码分析] Facebook如何训练超大模型 --- (3) 目录 [源码分析] Facebook如何训练超大模型 --- (3) 0x00 摘要 0x01 ZeRO-Offload 1.1 设计原 ...

  6. JavaWeb概念及Web资源的分类

    一,JavaWeb概念 1,JavaWeb,所有通过java语言编写可以通过浏览器访问的程序的总称 JavaWeb是基于请求和响应来开发的. 2,什么是请求 请求:指客户端给服务端发送数据,Reque ...

  7. 集合框架-工具类-Collections-其他方法将非同步集合转成同步集合的方法

    集合框架TXT  Collections-其他方法将非同步集合转成同步集合的方法

  8. Kubernetes 微服务最佳实践

    本文由个人笔记 ryan4yin/knowledge 整理而来 本文主要介绍我个人在使用 Kubernetes 的过程中,总结出的一套「Kubernetes 配置」,是我个人的「最佳实践」. 其中大部 ...

  9. Nginx请求连接限制

    目录 Nginx的请求限制 HTTP协议的连接与请求 连接限制 配置示例 做个演示: 请求限制 配置示例 基本指令 limit_req_zone limit_req zone 做个演示: Nginx的 ...

  10. linux文件压缩与文件夹压缩(打包)

    目录 一:linux文件压缩 1.linux常见的压缩包有哪些? 2.bzip压缩(文件) 二:打包(文件夹压缩) 1.打包命令 2.参数 3.参数解析(实战) 4.注意事项 简介: win中的压缩包 ...