Consul安装启动
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安装启动的更多相关文章
- Consul安装使用
安装 安装环境: Mac 我参照官网下载,然后解压,然后添加到PATH,并不能用.最终使用brew安装成功. brew install consul 安装成功后,文件位于/usr/local/Cell ...
- Consul安装集群搭建
1 consul的安装和配置 1.1 consul agent 命令介绍 下载consul_1.0.0_linux_amd64.zip解压,里面只有一个consul可执行文件,其中,consul最常用 ...
- postman使用之一:安装启动篇
官网介绍:http://www.getpostman.com/docs/ postman是干什么的就不介绍了,本文从postman的安装开始介绍,后续会有其它使用的介绍. 安装: 1.mac app安 ...
- consul 安装
1. linux 下consul 安装 首先查看机器信息: uname -a Linux centos-linux.shared 3.10.0-327.el7.x86_64 #1 SMP Thu No ...
- MySQL 安装 启动 基本语法概述
MySQL 安装 启动 基本语法概述 MySQL安装和配置 我是直接使用安装包:mysql-installer-community-5.6.10.1.msi 安装的时候其中有几点要注意: 1.记住端口 ...
- MySQL 安装 启动命令总结
MySQL 安装 启动 基本语法概述 MySQL安装和配置 我是直接使用安装包:mysql-installer-community-5.6.10.1.msi 安装的时候其中有几点要注意: 1.记住端口 ...
- mysql安装启动教程(两种方法)
mysql安装启动: 方法一(简单版): cmd进入mysql安装的bin目录:mysqld.exe –install net start mysql 服务启动(或者选择计算机->(右键)管理 ...
- Ubuntu 安装启动Tomcat
首先下载ubuntu 的tar包 官网: http://tomcat.apache.org/download-80.cgi 安装启动 1 .下载对应的tar 2 .解压任意文件夹下,更改名字tomca ...
- windows服务安装启动报错误1053:服务没有及时响应启动或控制请求
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0&qu ...
随机推荐
- HDU 1106 (1.3.5) 排序 (C语言描述)
排序 Problem Description 输入一行数字,如果我们把这行数字中的'5'都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以'0'开头,这些头部的'0'应该被忽略掉,除非 ...
- prtotype原型对象
js每个对象都拥有一个原型对象,每个对象都能从原型对象继承方法和属性,原型链就是基于原型对象而产生的, 也就是说,每个对象都能继承原型对象的方法和属性,这样一层一层的继承,就形成了原型链 当然,你也可 ...
- 【PTA】6-1 **删除C程序中的注释 (31 分)
请你编写一个函数,将C语言源程序中的注释全部删去. 函数原型 // 删除注释 void Pack(FILE *src, FILE *dst); 说明:参数 src 和 dst 均为文件指针,其中:sr ...
- 【C++】STL算法
STL算法 标签:c++ 目录 STL算法 一.不变序列算法 1.熟悉的min(), max() 2.找最值还自己动手么?不了不了 3.熟悉的find()和新学会的count() 二.变值算法 1.f ...
- 【刷题-LeetCode】222. Count Complete Tree Nodes
Count Complete Tree Nodes Given a complete binary tree, count the number of nodes. Note: Definition ...
- gin中的query和postform用法
package main import ( "github.com/gin-gonic/gin" ) func main() { r := gin.Default() // Que ...
- 带你十天轻松搞定 Go 微服务系列(六)
序言 我们通过一个系列文章跟大家详细展示一个 go-zero 微服务示例,整个系列分十篇文章,目录结构如下: 环境搭建 服务拆分 用户服务 产品服务 订单服务 支付服务(本文) RPC 服务 Auth ...
- python28day
内容回顾 classmethod: 用不到对象,并且要用类名的时候 装饰一个方法,被装饰的方法会变成类方法 staticmethod: 把一个函数放到类里,变成一个静态方法 这个方法既用不到对象,也用 ...
- JavaScripts之迪卡算法求积(n*n)适用于SKU信息计算等场景
迪卡算法求积(n * n) 使用 array.reduce 的方式实现 笛卡尔积算法 const arr = [ ['黑色', '白色', '蓝色'], ['1.2KG', '2.0KG', '3.0 ...
- Linux 安装和 连接xshell
一.介绍和安装 /*一.linux:? 为什么要学习它. 常见的操作系统? 1.windows, linux,mac 使用命令行进行操作 Windows cmd Linux 和Mac 中的命令行是 s ...