springboot 集成disconf

本文介绍了如何在SpringBoot项目中集成百度的分布式配置工具Disconf。通过创建profile目录,区分生产(aliyun_prod)和测试(test)环境的配置,并使用yml格式定义Disconf配置。接着,引入了spring-disconf.xml、spring-context.xml和spring-bean.xml等配置文件,最后在启动类中使用ImportResource导入相关XML,完成集成。
摘要由CSDN通过智能技术生成

springboot 集成disconf

关于分布式下的统一配置, 我们公司都用的是百度开源的disconf,虽然是一个半成品,但也能满足我们的需求,先看一下目录结构
这里写图片描述

首先 新建profile目录,下属两个文件夹,aliyun_prod 对应生产,test对应测试环境
test目录下采用yml格式来定义disconf的配置如下

disconf:
  enable:
    remote:
      conf: true
  conf_server_host: 127.0.0.1:3079
  version: 1_0_0_0
  app: paidui_soa
  env: LOCAL
  conf_server_url_retry_times: 2
  conf_server_url_retry_sleep_seconds: 1
  enable_local_download_dir_in_class_path: true

然后导入spring-disconf.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd">

    <!-- disconf 配置开始 -->
    <bean id="disconfMgrBean" class="com.baidu.disconf.client.DisconfMgrBean"
          destroy-method="destroy">
        <property name="scanPackage&#
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值