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-2010.水仙花数(C语言描述)
Problem Description 春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,他是这样定义的: "水仙花数"是指一个三位数,它的各位数字的立方和 ...
- nginx+php环境搭建详解(Linux)
今天在内网环境下,给linux主机安装nginx+php环境,由于是内网环境,只能手动解压缩包进行安装,在这过程中我也着实遇到了一些问题(困扰了我许久),还好最后搭建环境成功了,所以写篇博客记录一下, ...
- react中引入图片路劲正确但是页面上不显示或者打包后不能正常显示的问题
一.react中图片引入方式 以前我们用img引入图片只需要如下即可,在react中这样写会报错: <img src="../assets/zzsc1.png" /> ...
- MicroPython 8266 配置
MicroPython 8266 配置 刷固件 下载固件 MicroPython - Python for microcontrollers 从以上网址下载固件,本文下载的是esp8266-20210 ...
- WebGL 与 WebGPU 比对[1] 前奏
目录 1 为什么是 WebGPU 而不是 WebGL 3.0 显卡驱动 图形 API 的简单年表 WebGL 能运行在各个浏览器的原因 WebGPU 的名称由来 2 与 WebGL 比较编码风格 Op ...
- ctf--web刷题记录 ACTF2020back up file 、极客大挑战2019php、secret file
ACTF2020back up file backup file指的是备份文件,一般备份文件的后缀有".git" .".svn"." .swp&quo ...
- [STM32F10x] 利用定时器测量脉冲宽度
硬件:STM32F103C8T6 平台: ARM-MDk V5.11 前面一篇文章讲过如何利用定时器测量信号的频率(见[STM32F10x] 利用定时器测量频率),使用的是定时器的捕获/比较单元(Ca ...
- 1000粉!使用Three.js制作一个专属3D奖牌🥇
背景 破防了 !突然发现 SegmentFault 平台的粉丝数量已经突破 1000 了,它是我的三个博客平台掘金.博客园.SegmentFault中首个粉丝突破 1000 的,于是设计开发这个页面, ...
- Apple历代Mac系统汇总
编号 系统名 版本号 名称 发布时间 01 macOS 11.0 Big Sur(大惊喜) 2020年6月 02 macOS 10.15 Catalina(卡特琳娜) 2019年9月 03 macOS ...
- Linux 配置mysql 免安装版。
二.Linux配置 mysql ? 1.linux配置mysql(要求全部使用免安装版) 5.1.从官网下载mysql5.tar.gz 5.2.使用xftp把mysql的压缩包上传到服务器上 5.3. ...