config-server-eureka-bus-rabbitmq

1. File-->new spring starter project

2.add dependency

    <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

3.Edit application.yml

server:
port:
#spring cloud config native
spring:
profiles:
active: native
application:
name: config-server-eureka
cloud:
config:
server:
native:
search-locations: /home/smile/workspace-sts/config-repo
#spring cloud config git
#spring:
# application:
# name: config-server-eureka
# cloud:
# config:
# server:
# git:
# uri: http://localhost:3380/root/smile.git
# search-paths: config-repo
# username: root
# password: root123456 eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/ ## actuator refresh
management:
# server:
# port:
endpoint:
refresh:
enabled: true
endpoints:
web:
exposure:
include: '*'
# - info
# - health
# - refresh
#       include: '*' 开启所有接口。包含用到的 /actuator/bus-refresh

pplication.properties

## 开启消息跟踪
spring.cloud.bus.trace.enabled=true
##rabbimq
spring.rabbitmq.host=localhost
spring.rabbitmq.port=
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest spring.devtools.add-properties=false

4.program

package com.smile;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; @SpringBootApplication
@EnableEurekaClient
@EnableConfigServer
public class ConfigServerEurekaBusRabbitmqApplication { public static void main(String[] args) {
SpringApplication.run(ConfigServerEurekaBusRabbitmqApplication.class, args);
} }

5.Run

visit: http://localhost:8000/smile/config-dev

refresh :

post: localhost:8000/actuator/bus-refresh

config-client-eureka-bus-rabbitmq

1. File-->new spring project

2.add dependency

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

3.Edit bootstrap.yml

server:
port: spring:
application:
name: config-client-eureka
cloud:
config:
# uri: http://localhost:8000/
discovery:
enabled: true
service-id: config-server-eureka
name: smile
profile: config-dev
# dev 开发环境配置文件 | test 测试环境 | pro 正式环境 smile-config-dev.properties {name}-{profile}.properties
bus:
trace:
enabled: true
rabbitmq:
host: localhost
port:
username: guest
password: guest eureka:
client:
# registerWithEureka: false
# fetchRegistry: false
serviceUrl:
defaultZone: http://localhost:8761/eureka/ management:
endpoint:
refresh:
enabled: true
# endpoints:
# web:
# exposure:
# include: '*'
#此处不再需要手动刷新

4.program

package com.smile;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; @SpringBootApplication
@EnableEurekaClient
public class ConfigClientEurekaBusRabbitmqApplication { public static void main(String[] args) {
SpringApplication.run(ConfigClientEurekaBusRabbitmqApplication.class, args);
} }
package com.smile.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; @RestController
@RefreshScope
public class ConfigClientController { @Value("${name}")
String name;
@Value("${age}")
String age; @RequestMapping("/hello")
public String hello() {
return "name:"+name+",age:"+age;
}
}

5.Run

test

update smile-config-dev.properties  age=23-->age=24

post   http://localhost:8000/actuator/bus-refresh with firefox

visit  http://localhost:8003/hello/   this age is 24

spring cloud:config-eureka-refresh-bus-rabbitmq的更多相关文章

  1. Spring Cloud Security&Eureka安全认证(Greenwich版本)

    Spring Cloud Security&Eureka安全认证(Greenwich版本) 一·安全 Spring Cloud支持多种安全认证方式,比如OAuth等.而默认是可以直接添加spr ...

  2. spring Cloud 之 Eureka、Feign、Hystrix、Zuul、Config、Bus

    一.服务发现——Netflix Eureka Eureka包含两个组件: Eureka Server和Eureka Client 1.创建Eureka Server服务端 (1).引入依赖 父工程po ...

  3. springboot+cloud 学习(五)统一配置中心 spring cloud config + cloud bus + WebHooks +RibbitMQ

    前言 微服务要实现集中管理微服务配置.不同环境不同配置.运行期间也可动态调整.配置修改后可以自动更新的需求,Spring Cloud Config同时满足了以上要求.Spring Cloud Conf ...

  4. Greenwich.SR2版本的Spring Cloud Config+BUS实例

    Spring Cloud Config统一的配置中心同注册中心Eureka一样,也分服务端和客户端.服务端用来保存配置信息,客户端用来读取.它的优势是基于Git仓库,支持多环境.多分支配置.动态刷新. ...

  5. 跟我学SpringCloud | 第七篇:Spring Cloud Config 配置中心高可用和refresh

    SpringCloud系列教程 | 第七篇:Spring Cloud Config 配置中心高可用和refresh Springboot: 2.1.6.RELEASE SpringCloud: Gre ...

  6. 通过总线机制实现自动刷新客户端配置(Consul,Spring Cloud Config,Spring Cloud Bus)

    通过总线机制实现自动刷新客户端配置 方案示意图 利用Git服务的webhook通知功能,在每次更新配置之后,Git服务器会用POST方式调用配置中心的/actuator/bus-refresh接口,配 ...

  7. spring cloud config与eureka配合使用

    前面两篇介绍了Spring Cloud Config服务端和客户端的简单配置,本篇介绍Spring Cloud Config与Eureka配合使用 前言 默认情况下,配置客户端启动时,都是通过配置属性 ...

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

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

  9. Spring Cloud(九)高可用的分布式配置中心 Spring Cloud Config 集成 Eureka 服务

    上一篇文章,讲了SpringCloudConfig 集成Git仓库,这一篇我们讲一下SpringCloudConfig 配和 Eureka 注册中心一起使用 在分布式系统中,由于服务数量巨多,为了方便 ...

  10. .NET Core微服务之基于Steeltoe使用Spring Cloud Config统一管理配置

    Tip: 此篇已加入.NET Core微服务基础系列文章索引 =>  Steeltoe目录快速导航: 1. 基于Steeltoe使用Spring Cloud Eureka 2. 基于Steelt ...

随机推荐

  1. 3-app应用操作——Models.py和字段类型

    Models.py定义 每一个数据表对应一个model定义,model之间和java一样可以相互之间继承.所有的model都必须继承 from django.db import models#或间接继 ...

  2. js中index()的四种经典用法(转https://blog.csdn.net/superit401/article/details/51726826)

    <!doctype html><html lang="en"> <head> <meta charset="UTF-8" ...

  3. 字符集详解 ASCII码、Unicode、UTF-8 (转)

    认识字符集 对于计算机而言,它仅认识两个0和1,不管是在内存中还是外部存储设备上,我们所看到的文字.图片.视频等等“数据”在计算机中都是已二进制形式存在的.不同字符对应二进制数的规则,就是字符的编码. ...

  4. 微信小程序环境搭建(本地,测试,生产)

    1.本地 官网文档链接:https://cloud.tencent.com/document/product/619/11442#.E6.9C.AC.E5.9C.B0.E5.A6.82.E4.BD.9 ...

  5. C++ 临时对象的生存周期

    C++ 临时对象的生存周期是一个不小的坑,参考 C++ standard 第十二章第二节,总结其规则如下: 基本原则:临时变量生存到其所在的完整表达式执行完毕之后(若作为函数参数,则以函数所在的完整表 ...

  6. byteArray转换为double,int

    /*将int转为低字节在前,高字节在后的byte数组   b[0] = 11111111(0xff) & 01100001   b[1] = 11111111(0xff) & (n & ...

  7. AI换脸教程:DeepFaceLab使用教程(2.训练及合成)

    如果前期工作已经准备完毕(DeepFaceLab下载(https://www.deepfacelabs.com/list-5-1.html),然后安装相应的显卡驱动,DeepFaceLab使用教程(1 ...

  8. java选做猜数字

    程序设计思想 第一步:使用随机数生成1-100的数字 第二步:让用户输入数字 第三步:输入的数字与生成数字不同执行下一步,相同执行第五步 第四步:比较两数大小并输出结果,并返回第二步 第五步:输出猜对 ...

  9. hive中的null

    在处理流水增量表的时候,出现了一个判定的失误. select a.a1,a.a2 from ( select a.a1 ,,) as diff ,a.a2 from a lefter join b o ...

  10. Linux shell 下简单的进度条实现

    Linux shell 下简单的进度条实现 [root@db145 ~]# cat print_process.sh function Proceess(){ spa='' i= ] do print ...