spring cloud:config-eureka-refresh
config-server-eureka project
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.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>
spring-cloud-starter-netflix-eureka-client
</artifactId>
<version>2.1.1.RELEASE</version>
</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/
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 ConfigServerEurekaApplication { public static void main(String[] args) {
SpringApplication.run(ConfigServerEurekaApplication.class, args);
} }
5.Run
visit : http://localhost:8000/smile/config-dev

config-client-eureka
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.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
spring-boot-starter-actuator refresh 需要用到
3.Edit application.yml
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 eureka:
client:
# registerWithEureka: false
# fetchRegistry: false
serviceUrl:
defaultZone: http://localhost:8761/eureka/
application.yml
management:
# server:
# port:
endpoint:
refresh:
enabled: true
endpoints:
web:
exposure:
include:
- info
- health
- refresh
4.program
ConfigClientEurekaApplication
package com.smile; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; @SpringBootApplication
@EnableEurekaClient
@RefreshScope
public class ConfigClientEurekaApplication { public static void main(String[] args) {
SpringApplication.run(ConfigClientEurekaApplication.class, args);
} }
ConfigClientController
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
visit: http://localhost:8003/hello/


refresh:
update smile-config-dev.properties age=25--->age=15 save

post http://localhost:8003/actuator/refresh with firefox browser

visit: http://localhost:8003/hello/ age is changed
spring cloud:config-eureka-refresh的更多相关文章
- Spring Cloud Security&Eureka安全认证(Greenwich版本)
Spring Cloud Security&Eureka安全认证(Greenwich版本) 一·安全 Spring Cloud支持多种安全认证方式,比如OAuth等.而默认是可以直接添加spr ...
- 跟我学SpringCloud | 第七篇:Spring Cloud Config 配置中心高可用和refresh
SpringCloud系列教程 | 第七篇:Spring Cloud Config 配置中心高可用和refresh Springboot: 2.1.6.RELEASE SpringCloud: Gre ...
- spring cloud config与eureka配合使用
前面两篇介绍了Spring Cloud Config服务端和客户端的简单配置,本篇介绍Spring Cloud Config与Eureka配合使用 前言 默认情况下,配置客户端启动时,都是通过配置属性 ...
- spring cloud config搭建说明例子(二)-添加eureka
添加注册eureka 服务端 ConfigServer pom.xml <dependency> <groupId>org.springframework.cloud</ ...
- Spring Cloud(九)高可用的分布式配置中心 Spring Cloud Config 集成 Eureka 服务
上一篇文章,讲了SpringCloudConfig 集成Git仓库,这一篇我们讲一下SpringCloudConfig 配和 Eureka 注册中心一起使用 在分布式系统中,由于服务数量巨多,为了方便 ...
- spring Cloud 之 Eureka、Feign、Hystrix、Zuul、Config、Bus
一.服务发现——Netflix Eureka Eureka包含两个组件: Eureka Server和Eureka Client 1.创建Eureka Server服务端 (1).引入依赖 父工程po ...
- Spring Cloud Config
Spring Cloud Config provides server and client-side support for externalized configuration in a dist ...
- .NET Core微服务之基于Steeltoe使用Spring Cloud Config统一管理配置
Tip: 此篇已加入.NET Core微服务基础系列文章索引 => Steeltoe目录快速导航: 1. 基于Steeltoe使用Spring Cloud Eureka 2. 基于Steelt ...
- springboot+cloud 学习(五)统一配置中心 spring cloud config + cloud bus + WebHooks +RibbitMQ
前言 微服务要实现集中管理微服务配置.不同环境不同配置.运行期间也可动态调整.配置修改后可以自动更新的需求,Spring Cloud Config同时满足了以上要求.Spring Cloud Conf ...
- SpringCloud(6)分布式配置中心Spring Cloud Config
1.Spring Cloud Config 简介 在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件.在Spring Cloud中,有分布式配置中心组 ...
随机推荐
- c++ 判断点和圆位置关系(类的声明和类的实现分开)
Point.h: #pragma onceclass Point{private: double p_x, p_y;public: void setXY(double x,double y); dou ...
- css精灵图使用
1. 精灵技术的使用 CSS 精灵其实是将网页中的一些背景图像整合到一张大图中(精灵图),然而,各个网页元素通常只需要精灵图中不同位置的某个小图,要想精确定位到精灵图中的某个小图,就需要使用CSS的b ...
- Laravel5.8自定义函数存放位置
1. 创建文件 app/helpers.php <?php // 示例函数 function foo() { return "foo"; } 2. 修改项目 composer ...
- python简介与简单入门
1.计算机基础 计算机组成: 输入输出设备内. 存储器 .cpu .电源 .显卡 中央处理器(cpu) 处理各种数据 相当于人的大脑 内存 存储数据 相当于临时记忆 硬盘 存储数据 相当于人的永久记忆 ...
- python__基础数据类型
字符串和常用数据结构 使用字符串 第二次世界大战促使了现代电子计算机的诞生,当初的想法很简单,就是用计算机来计算导弹的弹道,因此在计算机刚刚诞生的那个年代,计算机处理的信息主要是数值,而世界上的第一台 ...
- 我所不知的JS
几天前在阅读 MDN 文档时我发现了一些我从来不知道的 JS 特性和 API. 下面是一份简短的清单, 无论有用不有用——学习 JS 的道路似乎是没有尽头的. 标签语句 在 JS 中,你可以对 for ...
- 4种vue当中的指令和它的用法
1.v-if:判断是否隐藏 2.v-for:数据循环 3.v-bind:class:绑定一个属性 4.v-model:实现数据双向绑定 这里重点说明一个v-if和v-show的区别: 共同点:都是通过 ...
- DSP、SSP、RTB、ADX(概念通俗解释)
DSP:需求方平台 比如小米想要投放一个新机发布的广告,那么他想在各大网站如网易.新浪UC等地方投放这条新机信息,但他不可能一个一个的去谈,费时费财不说,效率非常低. 于是他就去了一个平台,把打广告的 ...
- JVM内存分配和垃圾回收以及性能调优
JVM内存分配策略 一:堆中优先分配Eden 大多数情况下,对象都在新生代的Eden区中分配内存.而新生代会频繁进行垃圾回收. 二:大对象直接进入老年代 需要大量连续空间的对象,如:长字符串.数组等, ...
- Java RMI 最简单实例
IHello.java import java.rmi.Remote; import java.rmi.RemoteException; public interface IHello extends ...
