添加心跳

服务端 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的更多相关文章

  1. spring cloud config搭建说明例子(二)-添加eureka

    添加注册eureka 服务端 ConfigServer pom.xml <dependency> <groupId>org.springframework.cloud</ ...

  2. spring cloud config搭建说明例子(四)-补充配置文件

    服务端 ConfigServer pom.xml <dependency> <groupId>org.springframework.cloud</groupId> ...

  3. spring cloud config搭建说明例子(一)-简单示例

    服务端 ConfigServer pom.xml添加config jar <dependency> <groupId>org.springframework.cloud< ...

  4. SpringCloud实战之初级入门(三)— spring cloud config搭建git配置中心

    目录 1.环境介绍 2.配置中心 2.1 创建工程 2.2 修改配置文件 2.3 在github中加入配置文件 2.3 修改启动文件 3. 访问配置中心 1.环境介绍 上一篇文章中,我们介绍了如何利用 ...

  5. Spring Cloud Config 搭建Config 服务

    配置中心: open API 配置生效监控 一致性的K-V存储 统一配置的实时推送 配置全局恢复.备份.历史版本 高可用集群 通过config 获取配置,流程: 下面介绍,基于spring cloud ...

  6. 网络原因导致的 spring cloud config 读取git上的配置文件时报错:Cannot clone or checkout repository

    今天在公司使用spring cloud config搭建配置中心的时候,出现了读取不到git库的问题:Cannot clone or checkout repository.在网上百度,前面几个答案都 ...

  7. spring cloud config配置

    参考: http://www.ityouknow.com/springcloud/2017/05/22/springcloud-config-git.html http://www.ityouknow ...

  8. Spring Cloud Config(三):基于JDBC搭建配置中心

    1.简介 本文主要内容是基于jdbc搭建配置中心,使应用从配置中心读取配置信息并成功注册到注册中心,关于配置信息表结构仅供参考,大家可以根据具体需要进行扩展. 2.Config Server 搭建 2 ...

  9. 搭建spring cloud config

    很久没更新了,因为不是专职研究spring cloud,因此更新速度得看工作强度大不大,每天能抽出的时间不多,如果更新太慢了,并且有小伙伴看的话,请见谅了. Spring Cloud简介 Spring ...

随机推荐

  1. fd最大值和限制

    fd的数量决定了fd的最大值 在Linux下,系统全部能够打开的fd总数为: /proc/sys/fs/file-max,取决于内存 The file-max file /proc/sys/fs/fi ...

  2. hdu 1179最大匹配

    #include<stdio.h> #include<string.h> #define N 200 int map[N][N],visit[N],link[N],n,m; i ...

  3. POJ 3723 Conscription【最小生成树】

    题意: 征用一些男生和女生,每个应都要给10000元,但是如果某个男生和女生之间有关系,则给的钱数为10000减去相应的亲密度,征集一个士兵时一次关系只能使用一次. 分析: kruskal求最小生成树 ...

  4. Binary Tree Preorder Traversal (非递归实现)

    具体思路参见:二叉树的非递归遍历(转) 先序遍历(根左右). 即把每一个节点当做根节点来对待. /** * Definition for binary tree * struct TreeNode { ...

  5. Redis持久化方式--RDB和AOF

    转载于:https://www.cnblogs.com/xingzc/p/5988080.html Redis提供了RDB持久化和AOF持久化 RDB机制的优势和略施 RDB持久化是指在指定的时间间隔 ...

  6. Ubuntu 16.04 GNOME无法使用拼音输入法问题

    说明:添加好之后重启!不然会出现输入错乱的问题. 参考: http://forum.ubuntu.org.cn/viewtopic.php?t=477765

  7. omnidazzle是mac的画笔工具

    先使用命令 brew cask install omnidazzle 试试,不行参考下面: http://macappstore.org/omnidazzle/

  8. CentOS 7 开启VNC Service

    由於是透過 GUI 管理, 所以需要圖形桌面環境, 如果沒有安裝, 可以用以下指令安裝 GNOME: # yum groupinstall “GNOME Desktop” Centos 7安裝 VNC ...

  9. {head first} --- networking 1

    Head first系列的书确实非常好,深入浅出解说网络的组成.让曾经那些生涩的概念生动起来. Chapter 1 维修物理网络 CAT5电缆: 两端为RJ-45接头(水晶头).内部为UTP(非屏蔽双 ...

  10. 86. LotusScript中的数组函数

    R6对LotusScript有一些改进和增强,自那之后.Notes对象的接口时有补充和更新,但语言本身没有变化.那些改进就包括添加诸如ArrayGetIndex.ArrayUnique的实用函数. 但 ...