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. 使用 SourceGenerator 简化 Options 绑定

    目录 摘要 Options 绑定 使用 SourceGenerator 简化 如何 Debug SourceGenerator 如何 Format 生成的代码 使用方法 SourceCode & ...

  2. 《剑指offer》面试题03. 数组中重复的数字

    问题描述 找出数组中重复的数字. 在一个长度为 n 的数组 nums 里的所有数字都在 0-n-1 的范围内.数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次.请找出数组中 ...

  3. Cplex用法

    Cplex用法 1.将问题转化为LP问题: cplex -c read mps/nw460.mps change problem type lp opt 2.将问题转化为LP问题并输出问题: cple ...

  4. 【小记录】利用cuvid库做视频解码,运行出现"dlopen "libnvcuvid.so" failed!"

    1.查看源码:/Video_Codec_SDK_8.0.14/Samples/common/src/dynlink_nvcuvid.cpp 其中的LOAD_LIBRARY函数的源码如下: 1 #eli ...

  5. Ajax_Json用法

    Ajax_Json用法 关于json的服务端代码 //首先在方法里面设置一个响应json数据对象   const data = {       name:'chenxigua'   }​ //因为 s ...

  6. Shell 脚本循环遍历日志文件中的值进行求和并计算平均值,最大值和最小值

    本文为博主原创,转载请注明出处: 最近在进行压测,为了观察并定位服务性能的瓶颈,所以在代码中很多地方加了执行耗时的日志,但这种方式只能观察,却在压测的时候,不太能准确的把握代码中某些方法的性能,所以想 ...

  7. JavaFx 实现按钮防抖

    原文地址:JavaFx 实现按钮防抖 | Stars-One的杂货小窝 Android平台的APP,一般是有需要进行设置按钮的防抖(即在短时间内无法多次点击),我想在JavaFx项目中也是实现防抖功能 ...

  8. Python定制化天气预报消息推送

    sansui-Weather 代码码云 介绍 定制化天气预报消息推送(练手小脚本) Python脚本实现天气查询应用,提醒她注意保暖! 功能介绍 天气信息获取 当天天气信息提示 第二天天气信息提示 网 ...

  9. Asp-Net-Core学习笔记:身份认证入门

    前言 过年前我又来更新了~ 我就说了最近不是在偷懒吧,其实这段时间还是有积累一些东西的,不过还没去整理-- 所以只能发以前没写完的一些笔记出来 就当做是温习一下啦 PS:之前说的红包封面我还没搞,得抓 ...

  10. lambda表达式的学习

    Lambda表达式 为什么使用lambda表达式 Lambda表达式可以简化我们的代码,使我们只需要关注主要的代码就可以. //测试用的实体类 public class Employee { priv ...