原文:http://blog.csdn.net/qq_18675693/article/details/53337941

微服务:spring-cloud-archaius 起步

原创 2016年11月25日 18:13:05
  • 4596

Archaius是什么? 
一句话:可以动态的管理属性配置文件。使用相关的API使用属性就可以实现动态的数性加载。 
参考自Getting-Started

* 引入项目中*

<dependency>
<groupId>com.netflix.archaius</groupId>
<artifactId>archaius-core</artifactId>
<version>0.6.0</version>
</dependency>
  • 1
  • 2
  • 3
  • 4
  • 5

使用本地配置文件作为配置源

  • 默认的,Archaius将查找classpath下名为config.properties文件并读取,这个配置文件可以使包含在一个jar包的根路径下。
  • 另外,你可以使用属性archaius.configurationSource.additionalUrls来包含url形式的文件,多个文件用逗号分割。

可以使用下面的API在程序中得到你需要的属性

 // create a property whose value is type long and use 1000 as the default
// if the property is not defined
DynamicLongProperty timeToWait =
DynamicPropertyFactory.getInstance().getLongProperty("lock.waitTime", 1000);
// ...
ReentrantLock lock = ...;
// ...
lock.tryLock(timeToWait.get(), TimeUnit.MILLISECONDS); // timeToWait.get() returns up-to-date value of the property
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

默认的:Archaius会每一分钟去重新加载下属性配置 
注意:配置多属性文件时的属性覆盖,最后读到的属性会覆盖前面相同的属性

列出我们可以修改的一些系统属性

Operation HTTP action Notes
archaius.configurationSource.defaultFileName 指定Archaius默认加载的配置源属性文件名,默认:classpath:config.properties config.properties
archaius.fixedDelayPollingScheduler.initialDelayMills 延迟加载,默认30秒 30000
archaius.fixedDelayPollingScheduler.delayMills 两次属性读取时间间隔,默认1分钟 60000

高级使用:自定义configuration source和polling scheduler,即自己设计动态属性配置方案。

 
 

微服务:spring-cloud-archaius 起步的更多相关文章

  1. 微服务 | Spring Cloud(一):从单体SSM 到 Spring Cloud

    系列文章目录 微服务 | Spring Cloud(一):从单体SSM 到 Spring Cloud 目录 系列文章目录 前言 单体式架构 微服务架构 优点 缺点 服务发现与弹性扩展 参考 前言 在微 ...

  2. 微服务Spring Cloud与Kubernetes比较

    转 http://www.tuicool.com/articles/VnMf2y3 Spring Cloud或Kubernetes都宣称它们是开发运行微服务的最好环境,哪个更好?答案是两个都是,但他们 ...

  3. 微服务&spring cloud架构系列汇总

    为了方便查找,把微服务&微服务架构之spring cloud架构系列文章按时间正序整理了一下,记录如下:   1. 微服务架构之spring cloud 介绍 2. 微服务架构之spring ...

  4. SpringCloud---消息驱动的微服务---Spring Cloud Stream

    1.概述 1.1 Spring Cloud Stream:用来   为微服务应用   构建   消息驱动能力的框架: 可基于SpringBoot来创建独立.可用于生产的Spring应用程序: 使用Sp ...

  5. 网关服务Spring Cloud Gateway(二)

    上一篇文章服务网关 Spring Cloud GateWay 初级篇,介绍了 Spring Cloud Gateway 的相关术语.技术原理,以及如何快速使用 Spring Cloud Gateway ...

  6. 网关服务Spring Cloud Gateway(一)

    Spring 官方最终还是按捺不住推出了自己的网关组件:Spring Cloud Gateway ,相比之前我们使用的 Zuul(1.x) 它有哪些优势呢?Zuul(1.x) 基于 Servlet,使 ...

  7. SpringCloud---API网关服务---Spring Cloud Zuul

    1.概述 1.1 微服务架构出现的问题   及  解决: 1.1.1 前言 每个微服务应用都提供对外的Restful API服务,它通过F5.Nginx等网络设备或工具软件实现对各个微服务的路由与负载 ...

  8. 网关服务Spring Cloud Gateway(三)

    上篇文章介绍了 Gataway 和注册中心的使用,以及 Gataway 中 Filter 的基本使用,这篇文章我们将继续介绍 Filter 的一些常用功能. 修改请求路径的过滤器 StripPrefi ...

  9. Consul集群加入网关服务(Spring Cloud Gateway)

    Consul集群加入网关服务 架构示意图 外部的应用或网站通过外部网关服务消费各种服务,内部的生产者本身也可能是消费者,内部消费行为通过内部网关服务消费. 一个内部网关和一个外部网关以及一个Consu ...

  10. 网关服务spring cloud zuul

    Zuul例子配置文件 spring.application.name=switch-gateway server.port=5555 请求路由 传统路由方式 zuul.routes.api-a-url ...

随机推荐

  1. quazip 在windows msvc 2005 下的编译

    quazip 在windows  msvc 2005 下的编译 http://blog.csdn.net/v6543210/article/details/11661427

  2. C基础 内存统一入口

    引言  - malloc 引述 C标准中堆上内存入口就只有 malloc, calloc, realloc . 内存回收口是 free. 常见的一种写法是 struct person * per = ...

  3. 批量导出文件名 另存为bat文件

    @echo offdir /b *.* > 导出的文件名.txtexit

  4. mac下谷歌chrome浏览器的快捷键

    1. 标签页和窗口快捷键 ⌘-N 打开新窗口. ⌘-T 打开新标签页. ⌘-Shift-N 在隐身模式下打开新窗口. 按 ⌘-O,然后选择文件. 在 Chrome 浏览器中打开计算机中的文件. 按住  ...

  5. AC日记——[HNOI2014]世界树 bzoj 3572

    3572 思路: 虚树+乱搞: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 300005 #define ...

  6. 360杀毒导致的 VS 报扩展错误,请查看 ActiveLog.xml

    360杀毒将 TypeScript的 tsserver.js 列为木马,结果导致VS2017启动时,总是报错,将其加为信任即可解决.

  7. Centos7安装和配置NFS

    (1)nfs简介 作用:通过网络的不同的主机之间共享资源,支持多节点挂载并发写入 特点:单台,适合小型网络集群架构,非常稳定:大型公司使用(mfs,glusterfs,fastdfs) nfs优点:部 ...

  8. 日志 log4net

    先引入log4net 接着配置configuration文件 <?xml version="1.0"?><configuration> <system ...

  9. python selenium firefox 添加cookie add_cookie

    from selenium import webdriver driver = webdriver.Firefox() driver.get('http://www.baidu.com') cooki ...

  10. VMware8安装配置Win7、CentOS-7向导

    1.宿主电脑配置情况 Windows 8.1 中文版 Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz 2.4GHz RAM: 8G Type: 64 bit 2.软件 ...