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 ...
随机推荐
- JUC之线程池基础
线程池 定义和方法 线程池的工作时控制运行的线程数量,处理过程中将任务放入队列,然后在线程创建后启动这些任务,如果线程数量超过了最大数量,超出数量的线程排队等候,等待其他线程执行完成,再从队列中取出任 ...
- Solon 开发,七、自定义注解开发汇总
Solon 开发 一.注入或手动获取配置 二.注入或手动获取Bean 三.构建一个Bean的三种方式 四.Bean 扫描的三种方式 五.切面与环绕拦截 六.提取Bean的函数进行定制开发 七.自定义注 ...
- uniapp如何生成自己的小程序码并且携带参数
生成小程序码需要用到的参数appId appSecret这两个参数可以再微信公众平台里面登录获取 也可以用测试号里面的获取小程序码步骤1.首先要请求官方的API`https://api.weixin ...
- 使用 ES Module 的正确姿势
前面我们在深入理解 ES Module 中详细介绍过 ES Module 的工作原理.目前,ES Module 已经在逐步得到各大浏览器厂商以及 NodeJS 的原生支持.像 vite 等新一代的构建 ...
- Servlet-HttpServletResponse类介绍及作用和两个响应流介绍
Servlet-HttpServletResponse类 HttpServletResponse类和HttpServletRequest类一样.每次请求进来,Tomcat服务器都会创建一个Respon ...
- String类(获取,转换,判断,比较)
1 package cn.itcast.p1.string.demo; 2 3 import java.util.Iterator; 4 5 import com.sun.org.apache.xpa ...
- redis一主两从搭建
一主两从搭建: 主配: daemonize yes port 6379 logfile ./redis6379.log dir ./ bind 10.131.156.170 从1配: daemoniz ...
- JavaScript之 函数节流(Throttling) 与 防抖(Debounce)
Throttling:在监听鼠标移动事件.盒子滚动事件等使用节流技术能节省性能消耗 /** * 节流函数(每隔t执行一次) */ function Throttling(fn, t) { const ...
- Git使用教程(超全,看一篇就够了)
目录 Git介绍 Git安装 Git使用 问题与解决 推荐学习网址 Git介绍 Git是什么? Git是目前世界上最先进的分布式版本控制系统. SVN与Git的最主要的区别? SVN是集中式版本控制系 ...
- MySQL 事务的隔离级别及锁操作的一点点演示
MySQL 版本:5.7 安装环境:MAC OS 一.测试数据 测试数据库:test:测试表:tt CREATE TABLE `tt` ( `id` int(11) DEFAULT NULL, `na ...