该项目基于Consul作为注册发现,服务端以SpringBoot实现,无代码侵入模式编程,支持原生web应用(Servlet)
,Struts2,SpringProject。使用简单方便,配置自动更新,Git仓库配置文件一旦更改配置数据也
即刻刷新,不需要MQ。低侵入性或无侵入性、强兼容性。
- config-web 服务端
- config-client 客户端
Maven 引入
<dependency>
<groupId>org.nicosoft.config</groupId>
<artifactId>config-client</artifactId>
<version>1.0.1</version>
</dependency>
Spring 项目使用方法,引入config-client
包后在resource目录创建config.yml
:
config:
profile: dev # profile
token: er34xfwefwerqxrx2 # 交互的Token可有可无
consul:
host: localhost:8500 # consul 服务器地址
port: 8080 # 本地开放的端口
check: http://localhost:8080/health # 心跳检测地址
serviceId: config-client # 服务ID
serviceName: config-client # 服务器名
filePath: /home/travis/build/speedyproject/dcmp/config-client/repertory # 配置文件临时路径
创建好配置后,运行时在类成员上使用Spring原生@Value("${key}")
取值
文档持续更新中。。。。
- E-mail: gksqlsdy@gmail.com