Disconf的用途:专注于各种 分布式系统配置管理 的通用组件/通用平台, 提供统一的配置管理服务。
1.配置中心IP(重点)
域名:abc
不同环境会根据域名自动绑定到各自对应环境下的配置中心IP,本地调试环境需配置host
DEV:127.10.0.4:8081
进入C:\Windows\System32\drivers\etc目录
修改host文件,在空白处增加如下内容:
127.10.0.4 abc
2、开发
2.1 pom.xml添加jar包
<dependency>
<groupId>com.baidu.disconf</groupId>
<artifactId>disconf-client</artifactId>
<version>2.6.32</version>
</dependency>
3.在resource包下添加disconf.properties内容如下:
4.添加applicationContext-disconf.xml,这里放在resource/spring 包下
哪些配置需要下载,可以配置在value中,但前提是服务器上必须有
5、applicationContext-disconf.xml引入
applicationContext.xml 在文件中加入 (注意这里放在最靠前)
<!-- disconf 配置 -->
<import resource="spring/applicationContext-disconf.xml"/>
6.验证
验证正确的方法:
1.启动后查看download下是否有你配置的需要下载的文件。该文件每次启动时会覆盖。
2.查看是否将你下载的文件从download中考到了对应的目录下。