spring cloud config搭建说明例子(三)-添加actuator
添加心跳
服务端 ConfigServer
pom.xml添加actuator包
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
spring-cloud-starter-eureka与spring-cloud-starter-eureka-server的区别?
app不变
@EnableDiscoveryClient
@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
@EnableDiscoveryClient与@EnableEurekaClient的区别?
application.yml添加healthcheck
server:
port: ${PORT:8888} #配置工程端口号
spring:
application:
name: cloud-config-server #设置该服务应用名称
profiles:
active: native #设置读取为本地工程文件
config:
server:
native:
searchLocations: classpath:/config #配置文件根目录,也就是XXX-dev.properties等的目录
#注册到eureka服务中心进行监控
eureka:
client:
serviceUrl:
defaultZone: http://eureka:eureka@localhost:8761/eureka # 可以逗号分隔,配置多个
healthcheck:
enabled: true #开启健康监控
instance:
prefer-ip-address: true
instanceId: ${spring.application.name}:${spring.application.instance_id:${server.port}}
leaseRenewalIntervalInSeconds: 30
leaseExpirationDurationInSeconds: 90
官网也用发发发发这个端口。
配置文件
新建配置文件:
XXX-dev.properties
XXX-test.properties
客户端AppClient
pom.xml也需要增加autuator
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
bootstrap.properties配置不变
spring.cloud.config.name=XXX
spring.cloud.config.profile=dev
#spring.cloud.config.profile=test
spring.cloud.config.uri=http\://localhost\:8888/ # 只能配置一个,不能逗号分隔配置多个config
application.yml配置,和config一样增加health
server:
port: 8080 #设置当前服务端口
context-path: /abc #设置服务上下文路径
spring:
application:
name: app-client #service name 设置当前服务名称
eureka:
client:
serviceUrl:
defaultZone: http://eureka:eureka@localhost:8761/eureka # 可以逗号分隔,配置多个
healthcheck:
enabled: true
instance:
prefer-ip-address: true # 注册到Eureka Server上的是IP
instanceId: ${spring.application.name}:${spring.application.instance_id:${server.port}}
leaseRenewalIntervalInSeconds: 15 # 心跳时间,即服务续约间隔时间(缺省为30s)
leaseExpirationDurationInSeconds: 45 # 发呆时间,即服务续约到期时间(缺省为90s)
application类不变
@SpringBootApplication
@EnableEurekaClient
public class ClientApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(ClientApplication.class, args);
}
}
参考资料:
spring cloud config搭建说明例子(二)
spring cloud config搭建说明例子(三)-添加actuator的更多相关文章
- spring cloud config搭建说明例子(二)-添加eureka
添加注册eureka 服务端 ConfigServer pom.xml <dependency> <groupId>org.springframework.cloud</ ...
- spring cloud config搭建说明例子(四)-补充配置文件
服务端 ConfigServer pom.xml <dependency> <groupId>org.springframework.cloud</groupId> ...
- spring cloud config搭建说明例子(一)-简单示例
服务端 ConfigServer pom.xml添加config jar <dependency> <groupId>org.springframework.cloud< ...
- SpringCloud实战之初级入门(三)— spring cloud config搭建git配置中心
目录 1.环境介绍 2.配置中心 2.1 创建工程 2.2 修改配置文件 2.3 在github中加入配置文件 2.3 修改启动文件 3. 访问配置中心 1.环境介绍 上一篇文章中,我们介绍了如何利用 ...
- Spring Cloud Config 搭建Config 服务
配置中心: open API 配置生效监控 一致性的K-V存储 统一配置的实时推送 配置全局恢复.备份.历史版本 高可用集群 通过config 获取配置,流程: 下面介绍,基于spring cloud ...
- 网络原因导致的 spring cloud config 读取git上的配置文件时报错:Cannot clone or checkout repository
今天在公司使用spring cloud config搭建配置中心的时候,出现了读取不到git库的问题:Cannot clone or checkout repository.在网上百度,前面几个答案都 ...
- spring cloud config配置
参考: http://www.ityouknow.com/springcloud/2017/05/22/springcloud-config-git.html http://www.ityouknow ...
- Spring Cloud Config(三):基于JDBC搭建配置中心
1.简介 本文主要内容是基于jdbc搭建配置中心,使应用从配置中心读取配置信息并成功注册到注册中心,关于配置信息表结构仅供参考,大家可以根据具体需要进行扩展. 2.Config Server 搭建 2 ...
- 搭建spring cloud config
很久没更新了,因为不是专职研究spring cloud,因此更新速度得看工作强度大不大,每天能抽出的时间不多,如果更新太慢了,并且有小伙伴看的话,请见谅了. Spring Cloud简介 Spring ...
随机推荐
- tarjan 割点 割边
by GeneralLiu tarjan 求 割点 割边 无向图 的 割点 割边: 对于无向连通图来说, 如果删除 一个点以及与它相连的边 之后, 使得这个图不连通, 那么该点为割点 : ...
- idea使用之maven本地索引更新
idea使用起来的确挺顺手的,但遇到一些问题时,直接百度很难有答案,只能自己慢慢摸索了. 今天在倒腾idea仓库索引的时候,就出事情啦. 先说idea更新本地仓库索引吧,打开settings--> ...
- Linux下汇编语言学习笔记3 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- Ubuntu12.04之vi的问题
版本:ubuntu12.04. 问题:vi不能正常使用方向键与退格键. 原因:ubuntu系统自带的 vi 不完整导致. 解决方法:安装完整的vi,sudo apt-get install vim-g ...
- Rikka with Phi 线段树
Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds ...
- ZOJ3956 ZJU2017校赛(dp)
题意:给出n对(h,c) 记 sumh为选出的h的总和 sumc为选出的c的总和 你可以从中选出任意多对(可以不选) 使得 sumh^2-sumh*sumc-sumc^2 最大 输出最大值 输入 ...
- ADSL和ITV
1.ADSL和ITV两者占用的是不同的虚通道,也就是使用不同的VLAN: 2.的确上通过不同的VPI/VCI来区分ADSL和ITV在不同通道,但不会互不影响的,因为使用的还是同一条线路的宽带速度: 3 ...
- iOS 远程推送原理及实现
关于iOS 实现消息推送的原理: 1.provide[server]把要发送的消息,目的IOS设备标识打包.发送给APNS 2.APNS在自身已注冊Push服务的IOS设备列表中.查找有对应标识的IO ...
- 离线安装Cloudera Manager5.3.4与CDH5.3.4
文章转载:http://www.aboutyun.com/thread-14024-1-1.html 前期准备工作(系统环境搭建) 操作系统:CentOS 6.5 x64 CPU*2 64G 300G ...
- angular 的ui.router 定义不同的state 对应相同的url
Angular UI Router: Different states with same URL? The landing page of my app has two states: home-p ...