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. centos中安装python3.7

    1.1 CentOS 7编译安装Python3.7.X 1.安装依赖&下载python3.7 # 1.yum更新yum源 yum update # 2.安装Python 3.7所需的依赖否则安 ...

  2. 用slot和component实现表单共用

    业务需求 在oa开发中,有许多流程,每个流程里都会有很多字段,比如流程标题.拉下选择,附件等等,有些是每个流程都会有的,有些是特有的,按常规的方法开发,就为为一个流程写一个表单,校验,提交.如果新来流 ...

  3. django Paginator 让分页变得完美

    参考大佬地址:https://www.zmrenwu.com/courses/django-blog-tutorial/materials/21/ 类视图 from django.contrib.au ...

  4. hadoop面试复习笔记(1)

    0.Mappereduce采用的是Master/Slaves模型 1.Hadoop是一个开源软件框架,支持支持大数据集的存储和处理.Apache Hadoop是存储和处理大数据的解决方案你是因为: ( ...

  5. 使用Servlet实现验证码

    没有验证码带来的问题 对特定用户不断登录破解密码. 对某个网站创建账户. 对某个网站提交垃圾数据. 对某个网站刷票.  通过验证码由用户肉眼识别其中的验证码信息,从而区分用户是人还是计算机. 定义: ...

  6. sqlserver2008 必知必会技巧-- 快速索引对象

    对象资源管理器里面 -- 数据库 -- 表目录 ,然后按 f7 弹出 对象资源管理详细信息 , 里面有搜索栏 , 可以 使用 % 进行模糊查询 例如我们查包含 student的表 %student% ...

  7. 集群中Session共享解决方案分析

    一.为什么要Session共享 Session存储在服务器的内存中,比如Java中,Session存放在JVM的中,Session也可以持久化到file,MySQL,redis等,SessionID存 ...

  8. phpstorm 快捷键2

    1.跨平台. 2.对PHP支持refactor功能.支持断点调试,支持 Symfony2 和 Yii 的 MVC 视图 3.自动生成phpdoc的注释,非常方便进行大型编程. 4.内置支持Zencod ...

  9. caffe数据集LMDB的生成

    本文主要介绍如何在caffe框架下生成LMDB.其中包含了两个任务的LMDB生成方法,一种是分类,另外一种是检测. 分类任务 第一步  生成train.txt和test.txt文件文件 对于一个监督学 ...

  10. react-native启动时红屏报错:Unable to load script.Make sure you're either running a metro server or that ....

    一.报错信息内容 我是在Android Studio中运行启动react-native项目时报的这个错误 1.报错提示:Unable to load script.Make sure you're e ...