分布式配置管理平台之Disconf使用流程

本文介绍了一种名为Disconf的分布式系统配置管理工具,它通过统一的配置管理服务简化了配置文件的管理和应用。文章详细解释了如何在项目中集成Disconf,并提供了具体的配置示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

概念

    专注于各种「分布式系统配置管理」的「通用组件」和「通用平台」, 提供统一的「配置管理服务」。

使用流程

     第一步:去disconf服务器上上传自己项目的配置文件。

  1. 添加app,app名称对应自己的项目。
  2. 添加配置文件,版本自定义例如 0_0_2,然后选择输入方式,key值填youFile.properties下面的值填写自己所需要的配置(注:key:youFile.properties必须配置),配置的app名称和版本需和disconf配置文件中一致。

    第二步:如何使用spring配置disconf,如下步骤所示:

I、添加maven依赖:

<dependency>
    <groupId>com.nbugs.disconf.start</groupId>
    <artifactId>disconf</artifactId>
    <version>1.2.5</version>
</dependency>

II、添加disconf配置和disconf.properties在根目录下(resource目录下)

disconf.enable.remote.conf=true
disconf.conf_server_host=10.127.12.114
disconf.version=0_0_2
disconf.app=order_service
disconf.env=qa
disconf.ignore=
disconf.conf_server_url_retry_sleep_seconds=1
disconf.user_define_download_dir=./src/main/resources/config
disconf.common_app_conf_files_name=common.properties,datasource-user.properties,datasource-order.properties,mq.properties,redis-core.properties
disconf.app_conf_files_name=

III、修好/添加AppContext扫描文件路径

package myDisconf;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

@Configuration
@ImportResource(locations = { "classpath:spring/*", "classpath*:spring/disconf.xml" })
public class AppContext {
}

Disconf配置详解 所有的配置均可以通过命令行 -Dname=value参数传入。

配置说明默认值是否必填
disconf.conf_server_host配置服务器的HOST,用逗号分隔,示例:127.0.0.1:9000,127.0.0.1:9001 
disconf.appapp名称优先读取命令行参数,然后再读取此文件的值
disconf.version版本号默认DEFAULT_VERSION。优先读取命令行参数,然后再读取此文件的值,最后才读取默认值。
disconf.enable.remote.conf是否使用远程配置文件,默认(true)会从远程获取配置,false则直接获取本地配置false
disconf.env环境默认为DEFAULT_ENV.优先读取命令行参数,然后再读取此文件的值,最后才读取默认值。
disconf.ignore忽略的分布式配置,用空格分隔
disconf.debug

调试模式。调试模式下,ZK超时或断开连接后不会重新连接(常用于client单步debug)。非调试模式下,ZK超时或断开连接会自动重新连接。

false
disconf.conf_server_url_retry_times获取远程配置 重试时休眠时间,默认是3次3
disconf.conf_server_url_sleep_seconds获取远程配置 重试次数,默认是5秒5
disconf.user_define_download_dir

用户定义的下载文件夹, 远程文件下载后会放在这里。注意,此文件夹必须有有权限,否则无法下载到这里

./disconf/download/
disconf.enable_local_download_dir_in_class_path下载的文件会被迁移到classpath根路径下,强烈建议将此选项置为 true(默认是true)true
disconf.common_app通用配置app名称common
disconf.common_app_version通用配置app版本默认version
disconf.common_app_env通用配置环境默认与app环境相同
disconf.app_conf_files_nameapp多个配置文件加载配置;需要的配置文件中间用,号隔开;该配置下的文件只从app里面加载不填写的话,只会加载对应app下的specific.properties
disconf.common_app_conf_files_namecommon app多个配置文件加载配置;  
    

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值